Spaces:
Sleeping
Sleeping
Try OpenAI completion
Browse files- app.py +2 -6
- brander/app.py +22 -0
- brander/foo.py +0 -5
- poetry.lock +23 -1
- pyproject.toml +1 -0
- requirements.txt +1 -0
app.py
CHANGED
@@ -1,7 +1,3 @@
|
|
1 |
-
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
7 |
-
iface.launch()
|
|
|
1 |
+
from brander.app import interface
|
2 |
|
3 |
+
interface.launch()
|
|
|
|
|
|
|
|
brander/app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import openai
|
3 |
+
|
4 |
+
|
5 |
+
def greet(query: str):
|
6 |
+
completion = openai.ChatCompletion.create(
|
7 |
+
model="gpt-3.5-turbo",
|
8 |
+
messages=[
|
9 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
10 |
+
{"role": "user", "content": "Who won the world series in 2020?"},
|
11 |
+
{
|
12 |
+
"role": "assistant",
|
13 |
+
"content": "The Los Angeles Dodgers won the World Series in 2020.",
|
14 |
+
},
|
15 |
+
{"role": "user", "content": query},
|
16 |
+
],
|
17 |
+
)
|
18 |
+
return completion.choices[0].message.content
|
19 |
+
|
20 |
+
|
21 |
+
interface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
22 |
+
interface.launch()
|
brander/foo.py
DELETED
@@ -1,5 +0,0 @@
|
|
1 |
-
from brander.bar import baz
|
2 |
-
|
3 |
-
|
4 |
-
def greet(name):
|
5 |
-
return "Hello " + name + "!!" + baz
|
|
|
|
|
|
|
|
|
|
|
|
poetry.lock
CHANGED
@@ -1203,6 +1203,28 @@ files = [
|
|
1203 |
{file = "numpy-1.24.3.tar.gz", hash = "sha256:ab344f1bf21f140adab8e47fdbc7c35a477dc01408791f8ba00d018dd0bc5155"},
|
1204 |
]
|
1205 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1206 |
[[package]]
|
1207 |
name = "orjson"
|
1208 |
version = "3.8.14"
|
@@ -1992,4 +2014,4 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more
|
|
1992 |
[metadata]
|
1993 |
lock-version = "2.0"
|
1994 |
python-versions = "^3.9"
|
1995 |
-
content-hash = "
|
|
|
1203 |
{file = "numpy-1.24.3.tar.gz", hash = "sha256:ab344f1bf21f140adab8e47fdbc7c35a477dc01408791f8ba00d018dd0bc5155"},
|
1204 |
]
|
1205 |
|
1206 |
+
[[package]]
|
1207 |
+
name = "openai"
|
1208 |
+
version = "0.27.7"
|
1209 |
+
description = "Python client library for the OpenAI API"
|
1210 |
+
optional = false
|
1211 |
+
python-versions = ">=3.7.1"
|
1212 |
+
files = [
|
1213 |
+
{file = "openai-0.27.7-py3-none-any.whl", hash = "sha256:788fb7fa85bf7caac6c1ed7eea5984254a1bdaf09ef485acf0e5718c8b2dc25a"},
|
1214 |
+
{file = "openai-0.27.7.tar.gz", hash = "sha256:bca95fd4c3054ef38924def096396122130454442ec52005915ecf8269626b1d"},
|
1215 |
+
]
|
1216 |
+
|
1217 |
+
[package.dependencies]
|
1218 |
+
aiohttp = "*"
|
1219 |
+
requests = ">=2.20"
|
1220 |
+
tqdm = "*"
|
1221 |
+
|
1222 |
+
[package.extras]
|
1223 |
+
datalib = ["numpy", "openpyxl (>=3.0.7)", "pandas (>=1.2.3)", "pandas-stubs (>=1.1.0.11)"]
|
1224 |
+
dev = ["black (>=21.6b0,<22.0)", "pytest (==6.*)", "pytest-asyncio", "pytest-mock"]
|
1225 |
+
embeddings = ["matplotlib", "numpy", "openpyxl (>=3.0.7)", "pandas (>=1.2.3)", "pandas-stubs (>=1.1.0.11)", "plotly", "scikit-learn (>=1.0.2)", "scipy", "tenacity (>=8.0.1)"]
|
1226 |
+
wandb = ["numpy", "openpyxl (>=3.0.7)", "pandas (>=1.2.3)", "pandas-stubs (>=1.1.0.11)", "wandb"]
|
1227 |
+
|
1228 |
[[package]]
|
1229 |
name = "orjson"
|
1230 |
version = "3.8.14"
|
|
|
2014 |
[metadata]
|
2015 |
lock-version = "2.0"
|
2016 |
python-versions = "^3.9"
|
2017 |
+
content-hash = "47dc30dba1136c36fd2d50ca78c85d255ba0ff7a584e50ad1a3237ed90ef3aaf"
|
pyproject.toml
CHANGED
@@ -8,6 +8,7 @@ readme = "README.md"
|
|
8 |
[tool.poetry.dependencies]
|
9 |
python = "^3.9"
|
10 |
gradio = "^3.32.0"
|
|
|
11 |
|
12 |
|
13 |
[build-system]
|
|
|
8 |
[tool.poetry.dependencies]
|
9 |
python = "^3.9"
|
10 |
gradio = "^3.32.0"
|
11 |
+
openai = "^0.27.7"
|
12 |
|
13 |
|
14 |
[build-system]
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
openai==0.27.7
|