Spaces:
Sleeping
Sleeping
TintinMeimei
commited on
Commit
•
869823c
1
Parent(s):
64a4959
Update main.py
Browse files
main.py
CHANGED
@@ -1,12 +1,11 @@
|
|
1 |
from fastapi import FastAPI
|
2 |
-
|
3 |
-
|
4 |
|
5 |
app = FastAPI()
|
6 |
|
7 |
@app.get("/")
|
8 |
def read_root():
|
9 |
-
|
10 |
-
|
11 |
-
|
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}
|
|