File size: 1,021 Bytes
7b664dc
 
 
 
 
b898420
7b664dc
2123fad
 
 
 
 
f9b26a5
7b664dc
f3a7387
 
 
 
 
7b664dc
 
27b9508
7b664dc
 
 
 
27b9508
6d847d3
7b664dc
27b9508
 
7b664dc
 
 
 
9008411
d47b997
 
9008411
b898420
d47b997
7b664dc
 
 
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
38
39
40
41
42
43
44
45
#!/usr/bin/env python
# coding: utf-8

import os
import openai
import gradio

import torch
from diffusers import StableDiffusionPipeline
from torch import autocast


openai.api_key = os.getenv('openaikey')

def predict(input, manual_query_repacement, history=[]):

    if manual_query_repacement != "":
        input = manual_query_repacement
    
    response = openai.Completion.create(
    model="text-davinci-003",
    prompt=input,
    temperature=0.9,
    max_tokens=150,
    top_p=1,
    frequency_penalty=0,
    presence_penalty=0.6)
    
    # tokenize the new input sentence
    responseText = response["choices"][0]["text"]
    history.append((input, responseText))

    return history, history



inputText = gradio.Textbox(value="tmp")
manual_query = gradio.Textbox(placeholder="Input any query here, to replace the image generation query builder entirely.")

gradio.Interface(fn=predict,
             inputs=[inputText,manual_query,'state'],
            
             outputs=["chatbot",'state']).launch()