Spaces:
Sleeping
Sleeping
import openai | |
import gradio as gr | |
openai.api_key ='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' | |
def sentence_builder(donde,dias,quien,actividades): | |
return f"""Armar itineratio para viajar a {donde}, por {dias} dias, con {quien}, tener en cuenta que quiero hacer {" y ".join(actividades)}""" | |
def openai_chat(prompt): | |
completions = openai.Completion.create( | |
engine="text-davinci-003", | |
prompt=prompt+"The following is the prompt from teacher working in canvas infrastructure", | |
max_tokens=1024, | |
n=1, | |
temperature=0.5, | |
frequency_penalty=0, | |
presence_penalty=0.6, | |
stop=[" Human:", " AI:"] | |
) | |
message = completions.choices[0].text | |
return message.strip() | |
def chatbot(input, history=[]): | |
input = sentence_builder | |
output = openai_chat(input) | |
history.append((input, output)) | |
return history, history | |
demo = gr.Interface(sentence_builder, | |
[ | |
gr.Textbox(label="¿A donde queres ir?", lines=1, value="Roma"), | |
gr.Slider(1, 30, value=4), | |
gr.Dropdown(["solo/a", "amigos", "pareja", "familia"]), | |
gr.Dropdown(["puntos turisticos", "museos", "parques", "teatro", "trekking", "playas"], value=["puntos turisticos"], multiselect=True), | |
], | |
"text", | |
) | |
if __name__ == "__main__": | |
demo.launch() | |
quantity |