TintinMeimei commited on
Commit
869823c
1 Parent(s): 64a4959

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +5 -6
main.py CHANGED
@@ -1,12 +1,11 @@
1
  from fastapi import FastAPI
2
- # import openai
3
- # openai.api_key = "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"
4
 
5
  app = FastAPI()
6
 
7
  @app.get("/")
8
  def read_root():
9
- #input = "Translate this sentence to French. Sentence: I can speak Chinese."
10
- #output = openai.Completion.create(model="gpt-3.5-turbo", prompt="Translate")
11
- #return {"Input": input, "Output": output}
12
- return "Hello World"
 
1
  from fastapi import FastAPI
2
+ import openai
3
+ openai.api_key = "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"
4
 
5
  app = FastAPI()
6
 
7
  @app.get("/")
8
  def read_root():
9
+ input = {"role": "user", "content": "Translate this sentence to French. Sentence: I can speak Chinese."}
10
+ output = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=[input])
11
+ return {"Input": input, "Output": output}