File size: 1,152 Bytes
7b34ba5
 
15f25ed
7b34ba5
15f25ed
7b34ba5
 
15f25ed
7b34ba5
 
 
 
15f25ed
 
 
 
 
a401803
15f25ed
 
 
 
7b34ba5
 
15f25ed
7b34ba5
15f25ed
 
 
7b34ba5
 
15f25ed
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
from dotenv import load_dotenv
from openai import OpenAI
import gradio as gr

from langchain_openai import ChatOpenAI
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate
from langchain.chains import LLMChain
from langchain.memory import ConversationBufferMemory

load_dotenv()
OPENAI_SECRET_KEY= os.getenv("OPENAI_API_KEY")
client = OpenAI()
llm = ChatOpenAI(openai_api_key=OPENAI_SECRET_KEY,model="gpt-3.5-turbo-0125")
prompt = ChatPromptTemplate.from_messages([
    ("system","You are world class indian hindi standup comedian"),
    ("system","Shoaib and cybage team develop you"),
    ("user","{input}")
])

output_parser = StrOutputParser()


chain = prompt | llm | output_parser 

def my_function(message,history):
    response = chain.invoke({'input':message})
    print(response)
    return response

demo = gr.ChatInterface(
    my_function,
    chatbot=gr.Chatbot(height=500),
    title="Joke Bot",
    description="",
    theme="soft",
    examples=["Hello", "Tell me a joke?" ],
    retry_btn=None,
    undo_btn="Delete Previous",
    clear_btn="Clear",
)

demo.launch()