Tricia Nieva
Create app.py
3e530ed
raw
history blame
801 Bytes
#!/usr/bin/env python
# coding: utf-8
# In[ ]:
import os
import openai
import gradio as gr
openai.organization = "org-orRhfBkKOfOuNACbjPyWKbUt"
openai.api_key = "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"
def predict(input,initial_prompt, history=[]):
response = openai.Completion.create(
model="davinci:ft-placeholder:ai-dhd-2022-12-07-10-09-37",
prompt= initial_prompt + "\n" + str(s),
temperature=0.09,
max_tokens=608,
top_p=1,
frequency_penalty=0,
presence_penalty=0
)
# tokenize the new input sentence
response2 = response["choices"][0]["text"]
history.append((input, response2))
return history, history
gr.Interface(fn=predict,
inputs=["text","text",'state'],
outputs=["chatbot",'state']).launch()