COLLEAGUE-AI / app.py
MrAli813's picture
Update app.py
afc5ea9
raw
history blame
2.29 kB
import openai
import gradio as gr
openai.api_key = "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"
def predict(message, history):
history_openai_format = []
for human, assistant in history:
history_openai_format.append({"role": "user", "content": human })
history_openai_format.append({"role": "assistant", "content":assistant})
history_openai_format.append({"role": "user", "content": message})
response = openai.ChatCompletion.create(
model='gpt-3.5-turbo',
messages= history_openai_format,
temperature=1.0,
stream=True
)
partial_message = ""
for chunk in response:
if len(chunk['choices'][0]['delta']) != 0:
partial_message = partial_message + chunk['choices'][0]['delta']['content']
yield partial_message
A1 = gr.ChatInterface(predict,
title="PeachTalk+",
description="An AI Powered Chatbot with Computer Vision and Image Generation Capabilities Currently Under Development By Peach State Innovation and Technology. Ask Me About Question About Anything...From Georgia and Beyond...And I'll Give You An Answer!",
theme= gr.themes.Glass(primary_hue="amber", neutral_hue="lime"),
retry_btn=None,
clear_btn="Clear")
A2 = gr.load(
"huggingface/Salesforce/blip-image-captioning-large",
title="Upon Further Review...",
description="Upload or Take a Photo Image, I'll Give You Description",
outputs=[gr.Textbox(label="I see...")],
theme= gr.themes.Glass(primary_hue="amber", neutral_hue="lime"))
A3 = gr.load(
"huggingface/stabilityai/stable-diffusion-xl-base-1.0",
inputs=[gr.Textbox(label="Enter Your Description")],
outputs=[gr.Image(label="Image")],
title="Sailcloth",
description="Bring Your Imagination Into Existence With Stable Diffusion",
allow_flagging="never",
examples=["A ghastly spirit wandering the streets of Atlanta","A robot in a Brazilian favela"])
pcp = gr.TabbedInterface([A1, A2, A3], ["Chat", "Describe", "Create"], theme= gr.themes.Glass(primary_hue="amber", neutral_hue="lime"))
pcp.queue().launch()