Upload folder using huggingface_hub
Browse files- .idea/.gitignore +3 -0
- .idea/chatgpt_4o.iml +17 -0
- .idea/inspectionProfiles/Project_Default.xml +44 -0
- .idea/inspectionProfiles/profiles_settings.xml +6 -0
- .idea/misc.xml +7 -0
- .idea/modules.xml +8 -0
- .idea/workspace.xml +109 -0
- .venv/Lib/site-packages/gradio/launches.json +1 -1
- README.md +6 -6
- app_1.py +41 -0
- app_2.py +20 -0
- app_3.py +41 -0
.idea/.gitignore
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
# Default ignored files
|
2 |
+
/shelf/
|
3 |
+
/workspace.xml
|
.idea/chatgpt_4o.iml
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<module type="PYTHON_MODULE" version="4">
|
3 |
+
<component name="NewModuleRootManager">
|
4 |
+
<content url="file://$MODULE_DIR$">
|
5 |
+
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
6 |
+
</content>
|
7 |
+
<orderEntry type="jdk" jdkName="Python 3.12 (chatgpt_4o)" jdkType="Python SDK" />
|
8 |
+
<orderEntry type="sourceFolder" forTests="false" />
|
9 |
+
</component>
|
10 |
+
<component name="PyDocumentationSettings">
|
11 |
+
<option name="format" value="PLAIN" />
|
12 |
+
<option name="myDocStringFormat" value="Plain" />
|
13 |
+
</component>
|
14 |
+
<component name="TestRunnerService">
|
15 |
+
<option name="PROJECT_TEST_RUNNER" value="py.test" />
|
16 |
+
</component>
|
17 |
+
</module>
|
.idea/inspectionProfiles/Project_Default.xml
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<component name="InspectionProjectProfileManager">
|
2 |
+
<profile version="1.0">
|
3 |
+
<option name="myName" value="Project Default" />
|
4 |
+
<inspection_tool class="InconsistentLineSeparators" enabled="true" level="WARNING" enabled_by_default="true" />
|
5 |
+
<inspection_tool class="IncorrectFormatting" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
6 |
+
<inspection_tool class="LongLine" enabled="true" level="WARNING" enabled_by_default="true" />
|
7 |
+
<inspection_tool class="PyArgumentEqualDefaultInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
8 |
+
<inspection_tool class="PyClassicStyleClassInspection" enabled="true" level="WARNING" enabled_by_default="true" />
|
9 |
+
<inspection_tool class="PyCompatibilityInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
10 |
+
<option name="ourVersions">
|
11 |
+
<value>
|
12 |
+
<list size="2">
|
13 |
+
<item index="0" class="java.lang.String" itemvalue="2.7" />
|
14 |
+
<item index="1" class="java.lang.String" itemvalue="3.13" />
|
15 |
+
</list>
|
16 |
+
</value>
|
17 |
+
</option>
|
18 |
+
</inspection_tool>
|
19 |
+
<inspection_tool class="PyMandatoryEncodingInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
20 |
+
<option name="myAllPythons" value="true" />
|
21 |
+
</inspection_tool>
|
22 |
+
<inspection_tool class="PyMissingOrEmptyDocstringInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
23 |
+
<inspection_tool class="PyMissingTypeHintsInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
|
24 |
+
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
25 |
+
<option name="ignoredPackages">
|
26 |
+
<value>
|
27 |
+
<list size="8">
|
28 |
+
<item index="0" class="java.lang.String" itemvalue="beautifulsoup4" />
|
29 |
+
<item index="1" class="java.lang.String" itemvalue="certifi" />
|
30 |
+
<item index="2" class="java.lang.String" itemvalue="charset-normalizer" />
|
31 |
+
<item index="3" class="java.lang.String" itemvalue="lxml" />
|
32 |
+
<item index="4" class="java.lang.String" itemvalue="soupsieve" />
|
33 |
+
<item index="5" class="java.lang.String" itemvalue="requests" />
|
34 |
+
<item index="6" class="java.lang.String" itemvalue="urllib3" />
|
35 |
+
<item index="7" class="java.lang.String" itemvalue="idna" />
|
36 |
+
</list>
|
37 |
+
</value>
|
38 |
+
</option>
|
39 |
+
</inspection_tool>
|
40 |
+
<inspection_tool class="QodanaSanity" enabled="true" level="ERROR" enabled_by_default="true" />
|
41 |
+
<inspection_tool class="RestRoleInspection" enabled="true" level="WARNING" enabled_by_default="true" />
|
42 |
+
<inspection_tool class="TodoComment" enabled="true" level="WARNING" enabled_by_default="true" />
|
43 |
+
</profile>
|
44 |
+
</component>
|
.idea/inspectionProfiles/profiles_settings.xml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<component name="InspectionProjectProfileManager">
|
2 |
+
<settings>
|
3 |
+
<option name="USE_PROJECT_PROFILE" value="false" />
|
4 |
+
<version value="1.0" />
|
5 |
+
</settings>
|
6 |
+
</component>
|
.idea/misc.xml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="Black">
|
4 |
+
<option name="sdkName" value="Python 3.12 (chatgpt_4o)" />
|
5 |
+
</component>
|
6 |
+
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (chatgpt_4o)" project-jdk-type="Python SDK" />
|
7 |
+
</project>
|
.idea/modules.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="ProjectModuleManager">
|
4 |
+
<modules>
|
5 |
+
<module fileurl="file://$PROJECT_DIR$/.idea/chatgpt_4o.iml" filepath="$PROJECT_DIR$/.idea/chatgpt_4o.iml" />
|
6 |
+
</modules>
|
7 |
+
</component>
|
8 |
+
</project>
|
.idea/workspace.xml
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="AutoImportSettings">
|
4 |
+
<option name="autoReloadType" value="SELECTIVE" />
|
5 |
+
</component>
|
6 |
+
<component name="ChangeListManager">
|
7 |
+
<list default="true" id="926eef09-cdc9-4ba9-996b-c2fe9c05ff0d" name="Changes" comment="" />
|
8 |
+
<option name="SHOW_DIALOG" value="false" />
|
9 |
+
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
10 |
+
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
11 |
+
<option name="LAST_RESOLUTION" value="IGNORE" />
|
12 |
+
</component>
|
13 |
+
<component name="FileTemplateManagerImpl">
|
14 |
+
<option name="RECENT_TEMPLATES">
|
15 |
+
<list>
|
16 |
+
<option value="Python Script" />
|
17 |
+
</list>
|
18 |
+
</option>
|
19 |
+
</component>
|
20 |
+
<component name="ProjectColorInfo"><![CDATA[{
|
21 |
+
"associatedIndex": 3
|
22 |
+
}]]></component>
|
23 |
+
<component name="ProjectId" id="2gVqGmUlI5dGn9OOn3lns2Yvuio" />
|
24 |
+
<component name="ProjectViewState">
|
25 |
+
<option name="hideEmptyMiddlePackages" value="true" />
|
26 |
+
<option name="showLibraryContents" value="true" />
|
27 |
+
<option name="showMembers" value="true" />
|
28 |
+
</component>
|
29 |
+
<component name="PropertiesComponent"><![CDATA[{
|
30 |
+
"keyToString": {
|
31 |
+
"Python.app.executor": "Run",
|
32 |
+
"Python.app_1.executor": "Run",
|
33 |
+
"Python.app_2.executor": "Run",
|
34 |
+
"RunOnceActivity.ShowReadmeOnStart": "true",
|
35 |
+
"ignore.virus.scanning.warn.message": "true",
|
36 |
+
"last_opened_file_path": "D:/CODING/Projects/in_prog/chatgpt_4o"
|
37 |
+
}
|
38 |
+
}]]></component>
|
39 |
+
<component name="RunManager" selected="Python.app_2">
|
40 |
+
<configuration name="app_1" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
41 |
+
<module name="chatgpt_4o" />
|
42 |
+
<option name="ENV_FILES" value="" />
|
43 |
+
<option name="INTERPRETER_OPTIONS" value="" />
|
44 |
+
<option name="PARENT_ENVS" value="true" />
|
45 |
+
<envs>
|
46 |
+
<env name="PYTHONUNBUFFERED" value="1" />
|
47 |
+
</envs>
|
48 |
+
<option name="SDK_HOME" value="" />
|
49 |
+
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
50 |
+
<option name="IS_MODULE_SDK" value="true" />
|
51 |
+
<option name="ADD_CONTENT_ROOTS" value="true" />
|
52 |
+
<option name="ADD_SOURCE_ROOTS" value="true" />
|
53 |
+
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/app_1.py" />
|
54 |
+
<option name="PARAMETERS" value="" />
|
55 |
+
<option name="SHOW_COMMAND_LINE" value="false" />
|
56 |
+
<option name="EMULATE_TERMINAL" value="false" />
|
57 |
+
<option name="MODULE_MODE" value="false" />
|
58 |
+
<option name="REDIRECT_INPUT" value="false" />
|
59 |
+
<option name="INPUT_FILE" value="" />
|
60 |
+
<method v="2" />
|
61 |
+
</configuration>
|
62 |
+
<configuration name="app_2" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
63 |
+
<module name="chatgpt_4o" />
|
64 |
+
<option name="ENV_FILES" value="" />
|
65 |
+
<option name="INTERPRETER_OPTIONS" value="" />
|
66 |
+
<option name="PARENT_ENVS" value="true" />
|
67 |
+
<envs>
|
68 |
+
<env name="PYTHONUNBUFFERED" value="1" />
|
69 |
+
</envs>
|
70 |
+
<option name="SDK_HOME" value="" />
|
71 |
+
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
72 |
+
<option name="IS_MODULE_SDK" value="true" />
|
73 |
+
<option name="ADD_CONTENT_ROOTS" value="true" />
|
74 |
+
<option name="ADD_SOURCE_ROOTS" value="true" />
|
75 |
+
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/app_2.py" />
|
76 |
+
<option name="PARAMETERS" value="" />
|
77 |
+
<option name="SHOW_COMMAND_LINE" value="false" />
|
78 |
+
<option name="EMULATE_TERMINAL" value="false" />
|
79 |
+
<option name="MODULE_MODE" value="false" />
|
80 |
+
<option name="REDIRECT_INPUT" value="false" />
|
81 |
+
<option name="INPUT_FILE" value="" />
|
82 |
+
<method v="2" />
|
83 |
+
</configuration>
|
84 |
+
<recent_temporary>
|
85 |
+
<list>
|
86 |
+
<item itemvalue="Python.app_2" />
|
87 |
+
<item itemvalue="Python.app_1" />
|
88 |
+
</list>
|
89 |
+
</recent_temporary>
|
90 |
+
</component>
|
91 |
+
<component name="SharedIndexes">
|
92 |
+
<attachedChunks>
|
93 |
+
<set>
|
94 |
+
<option value="bundled-python-sdk-0509580d9d50-746f403e7f0c-com.jetbrains.pycharm.community.sharedIndexes.bundled-PC-241.14494.241" />
|
95 |
+
</set>
|
96 |
+
</attachedChunks>
|
97 |
+
</component>
|
98 |
+
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
99 |
+
<component name="TaskManager">
|
100 |
+
<task active="true" id="Default" summary="Default task">
|
101 |
+
<changelist id="926eef09-cdc9-4ba9-996b-c2fe9c05ff0d" name="Changes" comment="" />
|
102 |
+
<created>1715793002243</created>
|
103 |
+
<option name="number" value="Default" />
|
104 |
+
<option name="presentableId" value="Default" />
|
105 |
+
<updated>1715793002243</updated>
|
106 |
+
</task>
|
107 |
+
<servers />
|
108 |
+
</component>
|
109 |
+
</project>
|
.venv/Lib/site-packages/gradio/launches.json
CHANGED
@@ -1 +1 @@
|
|
1 |
-
{"launches":
|
|
|
1 |
+
{"launches": 9}
|
README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
---
|
2 |
-
title: chatbot
|
3 |
-
app_file: D:\CODING\Projects\in_prog\chatgpt_4o\app.py
|
4 |
-
sdk: gradio
|
5 |
-
sdk_version: 4.31.2
|
6 |
-
---
|
|
|
1 |
+
---
|
2 |
+
title: chatbot
|
3 |
+
app_file: D:\CODING\Projects\in_prog\chatgpt_4o\app.py
|
4 |
+
sdk: gradio
|
5 |
+
sdk_version: 4.31.2
|
6 |
+
---
|
app_1.py
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from dotenv import load_dotenv
|
3 |
+
from openai import Client
|
4 |
+
import gradio as gr
|
5 |
+
|
6 |
+
# Load environment variables from .env file
|
7 |
+
load_dotenv()
|
8 |
+
|
9 |
+
# Get the value of the environment variable
|
10 |
+
api_key = os.getenv('OPENAI_API_KEY')
|
11 |
+
|
12 |
+
if not api_key:
|
13 |
+
raise ValueError("API key not found. Please set your OPENAI_API_KEY in the environment.")
|
14 |
+
|
15 |
+
# Initialize the OpenAI client
|
16 |
+
client = Client(api_key=api_key)
|
17 |
+
|
18 |
+
def chatbot(input):
|
19 |
+
"""Chatbot function using the OpenAI API"""
|
20 |
+
if input:
|
21 |
+
messages = [
|
22 |
+
{"role": "system", "content": "You are a helpful and kind AI Assistant."},
|
23 |
+
{"role": "user", "content": input},
|
24 |
+
]
|
25 |
+
response = client.chat.complete(
|
26 |
+
engine="text-davinci-003",
|
27 |
+
messages=messages,
|
28 |
+
max_tokens=150,
|
29 |
+
n=1,
|
30 |
+
stop=None,
|
31 |
+
temperature=0.7,
|
32 |
+
)
|
33 |
+
reply = response.choices[0].text
|
34 |
+
return reply
|
35 |
+
|
36 |
+
input_text = gr.Textbox(lines=7, label="Chat with AI")
|
37 |
+
output_text = gr.Textbox(label="Reply")
|
38 |
+
|
39 |
+
chatbot_interface = gr.Interface(fn=chatbot, inputs=input_text, outputs=output_text, title="AI Chatbot",
|
40 |
+
description="Ask anything you want", theme="compact")
|
41 |
+
chatbot_interface.launch(share=True)
|
app_2.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from openai import ChatCompletion
|
2 |
+
|
3 |
+
# Define the prompt for the chatbot
|
4 |
+
prompt = "You are OpenGPT 4o, a highly knowledgeable and intelligent multitalented AI assistant created by KingNish, referred to as Assistant. In the following interactions, User and Assistant will converse in natural language, and Assistant will do its best to answer User's questions. Assistant has the ability to perceive images, answer Users question fom images, generate images, chat with user, bulk creation of any of this and reason about them. Assistant knows a lot, and always tells the truth, it does not make up facts. Assistant can even bulk generate images just by increasing amount of link, Assistant Must write link in format ![](link) , Bulk image gen Example:"
|
5 |
+
|
6 |
+
[USER] Create 7 image each consist of 1 wonder from 7 wonders.
|
7 |
+
[ASSISTANT] Generating Images ...
|
8 |
+
"1. A photorealistic image of the Great Pyramid of Giza in Egypt. ![](https://pollinations.ai/p/a-photorealistic-image-of-the-great-pyramid-of-giza-in-egypt-showcasing-its-immense-size-and-intricate-design-against-the-backdrop-of-a-clear-blue-sky?width=1920&height=1080&nologo=poll&seed=78182)"
|
9 |
+
"2. A 3D rendering of the Colosseum in Rome, Italy, ![](https://pollinations.ai/p/a-3d-rendering-of-the-colosseum-in-rome-italy-with-its-impressive-structure-and-historical-significance-highlighted-in-the-image-include-realistic-lighting-and-textures-for-added-detail?width=1200&height=1600&nologo=poll&seed=91531)"
|
10 |
+
"3. A painting of the Taj Mahal in Agra, India, ![](https://pollinations.ai/p/a-painting-of-the-taj-mahal-in-aga-india-depicting-its-iconic-white-marble-facade-and-intricate-architectural-details-capture-the-beauty-of-the-structure-against-a-serene-sunset?width=1080&height=900&nologo=poll&seed=34251)"
|
11 |
+
"4. A cartoon illustration of the Great Wall of China, ![](https://pollinations.ai/p/a-cartoon-illustration-of-the-great-wall-of-china-featuring-a-fun-and-whimsical-representation-of-the-ancient-structure-winding-through-the-mountains-add-colorful-elements-and-quirky-characters-for-a-playful-touch?width=1600&height=900&nologo=poll&seed=93015)"
|
12 |
+
"5. A surreal, dreamlike depiction of Chichen Itza in Mexico, ![](https://pollinations.ai/p/a-surreal-dreamlike-depiction-of-chichen-itza-in-mexico-showcasing-the-ancient-mayan-city's-iconic-el-castillo-pyramid-incorporate-mystical-elements-like-swirling-clouds-glowing-lights-and-ethereal-landscapes-to-create-a-mesmerizing-atmosphere?width=1440&height=2560&nologo=poll&seed=67281)"
|
13 |
+
"6. A vintage, sepia-toned photograph of Machu Picchu in Peru, ![](https://pollinations.ai/p/a-vintage-sepia-toned-photograph-of-machu-picchu-in-peru-highlighting-the-incan-ruins's-iconic-el-castillo-pyramid-use-subtle-details-like-foggy-mountains-and-a-peaceful-river-to-enhance-the-image's-atmosphere?width=2560&height=1440&nologo=poll&seed=93423)"
|
14 |
+
"7. A modern, minimalistic image of Petra in Jordan, ![](https://pollinations.ai/p/a-modern-minimalistic-image-of-petra-in-jordan-featuring-the-iconic-treasury-building-carved-into-the-sandstone-cliffs-use-clean-lines-a-muted-color-palette-and-a-minimalistic-approach-to-create-a-contemporary-and-visually-striking-representation-of-this-ancient-wonder?width=1024&height=1024&nologo=poll&seed=67693)"
|
15 |
+
|
16 |
+
# Call the OpenAI API to generate the chatbot4o
|
17 |
+
chatbot4o = ChatCompletion.create(model="gpt-3.text-davinci-003", prompt=prompt, temperature=0.5, max_length=1024, frequency_penalty=0.1, presence_penalty=0.1)
|
18 |
+
|
19 |
+
# Print the generated chatbot4o
|
20 |
+
print(chatbot4o)
|
app_3.py
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from dotenv import load_dotenv
|
3 |
+
from openai import Client
|
4 |
+
import gradio as gr
|
5 |
+
|
6 |
+
# Load environment variables from .env file
|
7 |
+
load_dotenv()
|
8 |
+
|
9 |
+
# Get the value of the environment variable
|
10 |
+
api_key = os.getenv('OPENAI_API_KEY')
|
11 |
+
|
12 |
+
if not api_key:
|
13 |
+
raise ValueError("API key not found. Please set your OPENAI_API_KEY in the environment.")
|
14 |
+
|
15 |
+
# Initialize the OpenAI client
|
16 |
+
client = Client(api_key=api_key)
|
17 |
+
|
18 |
+
def chatbot(input):
|
19 |
+
"""Chatbot function using the OpenAI API"""
|
20 |
+
if input:
|
21 |
+
messages = [
|
22 |
+
{"role": "system", "content": "You are a helpful and kind AI Assistant."},
|
23 |
+
{"role": "user", "content": input},
|
24 |
+
]
|
25 |
+
response = client.chat.complete(
|
26 |
+
engine="text-davinci-003",
|
27 |
+
messages=messages,
|
28 |
+
max_tokens=150,
|
29 |
+
n=1,
|
30 |
+
stop=None,
|
31 |
+
temperature=0.7,
|
32 |
+
)
|
33 |
+
reply = response.choices[0].text
|
34 |
+
return reply
|
35 |
+
|
36 |
+
input_text = gr.Textbox(lines=7, label="Chat with AI")
|
37 |
+
output_text = gr.Textbox(label="Reply")
|
38 |
+
|
39 |
+
chatbot_interface = gr.Interface(fn=chatbot, inputs=input_text, outputs=output_text, title="AI Chatbot",
|
40 |
+
description="Ask anything you want", theme="compact")
|
41 |
+
chatbot_interface.launch(share=True)
|