Spaces:
Sleeping
Sleeping
John Doe
commited on
Commit
·
11526c9
1
Parent(s):
46e67e4
some fixes
Browse files
app.py
CHANGED
|
@@ -1,23 +1,25 @@
|
|
| 1 |
import asyncio
|
| 2 |
import datetime
|
|
|
|
| 3 |
|
| 4 |
import gradio as gr
|
| 5 |
|
| 6 |
import koil
|
| 7 |
|
|
|
|
| 8 |
from lm.lm.openai import openai
|
| 9 |
from lm.log.arweaveditems import arweaveditems
|
| 10 |
|
| 11 |
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
| 12 |
|
| 13 |
-
|
| 14 |
-
async def predict(input):
|
| 15 |
timestamp = datetime.datetime.now().isoformat()
|
| 16 |
try:
|
| 17 |
api = openai(api_key = OPENAI_API_KEY)
|
| 18 |
except:
|
| 19 |
api = openai(api_key = OPENAI_API_KEY, model = 'gpt-4')
|
| 20 |
-
|
|
|
|
| 21 |
response = await api(input)
|
| 22 |
addr = await log(
|
| 23 |
timestamp = timestamp,
|
|
@@ -29,6 +31,10 @@ async def predict(input):
|
|
| 29 |
print(addr)
|
| 30 |
return [addr, response]
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
def reset_textbox():
|
| 33 |
return gr.update(value='')
|
| 34 |
|
|
@@ -53,8 +59,8 @@ with gr.Blocks(css = """#col_container { margin-left: auto; margin-right: auto;}
|
|
| 53 |
with gr.Row():
|
| 54 |
with gr.Column(scale=7):
|
| 55 |
b1 = gr.Button().style(full_width=True)
|
| 56 |
-
with gr.Column(scale=3):
|
| 57 |
-
|
| 58 |
|
| 59 |
#inputs, top_p, temperature, top_k, repetition_penalty
|
| 60 |
#with gr.Accordion("Parameters", open=False):
|
|
|
|
| 1 |
import asyncio
|
| 2 |
import datetime
|
| 3 |
+
import os
|
| 4 |
|
| 5 |
import gradio as gr
|
| 6 |
|
| 7 |
import koil
|
| 8 |
|
| 9 |
+
|
| 10 |
from lm.lm.openai import openai
|
| 11 |
from lm.log.arweaveditems import arweaveditems
|
| 12 |
|
| 13 |
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
| 14 |
|
| 15 |
+
async def apredict(input):
|
|
|
|
| 16 |
timestamp = datetime.datetime.now().isoformat()
|
| 17 |
try:
|
| 18 |
api = openai(api_key = OPENAI_API_KEY)
|
| 19 |
except:
|
| 20 |
api = openai(api_key = OPENAI_API_KEY, model = 'gpt-4')
|
| 21 |
+
log = arweaveditems()
|
| 22 |
+
async with api, log:
|
| 23 |
response = await api(input)
|
| 24 |
addr = await log(
|
| 25 |
timestamp = timestamp,
|
|
|
|
| 31 |
print(addr)
|
| 32 |
return [addr, response]
|
| 33 |
|
| 34 |
+
def predict(input):
|
| 35 |
+
with koil.Koil() as Koil:
|
| 36 |
+
return koil.unkoil(apredict, input)
|
| 37 |
+
|
| 38 |
def reset_textbox():
|
| 39 |
return gr.update(value='')
|
| 40 |
|
|
|
|
| 59 |
with gr.Row():
|
| 60 |
with gr.Column(scale=7):
|
| 61 |
b1 = gr.Button().style(full_width=True)
|
| 62 |
+
#with gr.Column(scale=3):
|
| 63 |
+
# server_status_code = gr.Textbox(label="Status code from OpenAI server", )
|
| 64 |
|
| 65 |
#inputs, top_p, temperature, top_k, repetition_penalty
|
| 66 |
#with gr.Accordion("Parameters", open=False):
|