Professional Documents
Culture Documents
120a1110 - Ai - Mini Proj
120a1110 - Ai - Mini Proj
Executive Summary:
The rapid growth of chatbots in recent years has led to the development
of more advanced and sophisticated bots, powered by Artificial
Intelligence (AI). OpenAI API-based Chat Bots are one such type of bot
that utilizes the OpenAI API to generate natural language responses.
These chatbots can be customized to meet specific business needs, and
they have the potential to improve customer engagement and
satisfaction.
Introduction:
Thirdly, OpenAI API-based Chat Bots are scalable and can handle a large
volume of customer queries. This can save time and resources for
businesses, as they can handle a high volume of customer inquiries
without requiring additional staff.
OpenAI API-based Chat Bots have several key features that make them
unique. These include:
Code:-
import os
import openai
import gradio as gr
openai.api_key = "sk-
459iFC6LsffytoLApp9hT3BlbkFJdna7vghyBVxLsiSU1UlU"
start_sequence = "\nAI:"
restart_sequence = "\nHuman: "
response = openai.Completion.create(
model="text-davinci-003",
prompt=prompt,
temperature=0.9,
max_tokens=150,
top_p=1,
frequency_penalty=0,
presence_penalty=0.6,
stop=[" Human:", " AI:"]
)
return response.choices[0].text
with block:
gr.Markdown("""<h1><center>ChatBot with OpenAI API &
Gradio</center></h1>
""")
chatbot = gr.Chatbot()
message = gr.Textbox(placeholder=prompt)
state = gr.State()
submit = gr.Button("SEND")
submit.click(chatgpt_clone, inputs=[message, state], outputs=[chatbot,
state])
block.launch(debug = True)
Output:-
Conclusion:-