File size: 801 Bytes
3e530ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/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()