Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files- .env +3 -0
- .ipynb_checkpoints/gradio-app-checkpoint.ipynb +98 -0
- .ipynb_checkpoints/langchain-app-checkpoint.ipynb +55 -0
- README.md +2 -8
- langchain-app.ipynb +99 -0
.env
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
OPENAI_API_KEY='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'
|
2 |
+
PINECONE_ENV='gcp-starter'
|
3 |
+
PINECONE_API_KEY='9c64a98d-d7d3-4409-b108-c294a7a8c469s'
|
.ipynb_checkpoints/gradio-app-checkpoint.ipynb
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 2,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [
|
8 |
+
{
|
9 |
+
"name": "stdout",
|
10 |
+
"output_type": "stream",
|
11 |
+
"text": [
|
12 |
+
"Running on local URL: http://127.0.0.1:7860\n",
|
13 |
+
"Running on public URL: https://0e417036a0cfaf8a4d.gradio.live\n",
|
14 |
+
"\n",
|
15 |
+
"This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n"
|
16 |
+
]
|
17 |
+
},
|
18 |
+
{
|
19 |
+
"data": {
|
20 |
+
"text/html": [
|
21 |
+
"<div><iframe src=\"https://0e417036a0cfaf8a4d.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
22 |
+
],
|
23 |
+
"text/plain": [
|
24 |
+
"<IPython.core.display.HTML object>"
|
25 |
+
]
|
26 |
+
},
|
27 |
+
"metadata": {},
|
28 |
+
"output_type": "display_data"
|
29 |
+
},
|
30 |
+
{
|
31 |
+
"data": {
|
32 |
+
"text/plain": []
|
33 |
+
},
|
34 |
+
"execution_count": 2,
|
35 |
+
"metadata": {},
|
36 |
+
"output_type": "execute_result"
|
37 |
+
}
|
38 |
+
],
|
39 |
+
"source": [
|
40 |
+
"import gradio as gr\n",
|
41 |
+
"\n",
|
42 |
+
"def takeinput(name):\n",
|
43 |
+
" str_input = \"Hello {name} how are you?\"\n",
|
44 |
+
" return str_input\n",
|
45 |
+
"\n",
|
46 |
+
"demo = gr.Interface(\n",
|
47 |
+
" fn=takeinput,\n",
|
48 |
+
" inputs=[\"text\"],\n",
|
49 |
+
" outputs=[\"text\"]\n",
|
50 |
+
")\n",
|
51 |
+
"\n",
|
52 |
+
"demo.launch(share=True)"
|
53 |
+
]
|
54 |
+
},
|
55 |
+
{
|
56 |
+
"cell_type": "code",
|
57 |
+
"execution_count": null,
|
58 |
+
"metadata": {},
|
59 |
+
"outputs": [],
|
60 |
+
"source": []
|
61 |
+
},
|
62 |
+
{
|
63 |
+
"cell_type": "code",
|
64 |
+
"execution_count": null,
|
65 |
+
"metadata": {},
|
66 |
+
"outputs": [],
|
67 |
+
"source": []
|
68 |
+
},
|
69 |
+
{
|
70 |
+
"cell_type": "code",
|
71 |
+
"execution_count": null,
|
72 |
+
"metadata": {},
|
73 |
+
"outputs": [],
|
74 |
+
"source": []
|
75 |
+
}
|
76 |
+
],
|
77 |
+
"metadata": {
|
78 |
+
"kernelspec": {
|
79 |
+
"display_name": "Python 3 (ipykernel)",
|
80 |
+
"language": "python",
|
81 |
+
"name": "python3"
|
82 |
+
},
|
83 |
+
"language_info": {
|
84 |
+
"codemirror_mode": {
|
85 |
+
"name": "ipython",
|
86 |
+
"version": 3
|
87 |
+
},
|
88 |
+
"file_extension": ".py",
|
89 |
+
"mimetype": "text/x-python",
|
90 |
+
"name": "python",
|
91 |
+
"nbconvert_exporter": "python",
|
92 |
+
"pygments_lexer": "ipython3",
|
93 |
+
"version": "3.11.4"
|
94 |
+
}
|
95 |
+
},
|
96 |
+
"nbformat": 4,
|
97 |
+
"nbformat_minor": 4
|
98 |
+
}
|
.ipynb_checkpoints/langchain-app-checkpoint.ipynb
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": null,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [],
|
8 |
+
"source": [
|
9 |
+
"import os\n",
|
10 |
+
"import gradio as gr\n",
|
11 |
+
"from dotenv import load_dotenv, find_dotenv\n",
|
12 |
+
"_ = load_dotenv(find_dotenv())\n",
|
13 |
+
"\n",
|
14 |
+
"from langchain.chains import ConversationChain\n",
|
15 |
+
"from langchain.chat_models import ChatOpenAI\n",
|
16 |
+
"from langchain.memory import ConversationBufferMemory\n",
|
17 |
+
"\n",
|
18 |
+
"llm = ChatOpenAI(temperature=0.0)\n",
|
19 |
+
"memory = ConversationBufferMemory()\n",
|
20 |
+
"conversion = ConversationChain(\n",
|
21 |
+
" llm=llm,\n",
|
22 |
+
" memory=memory,\n",
|
23 |
+
" verbose=False\n",
|
24 |
+
")\n",
|
25 |
+
"\n",
|
26 |
+
"def takeinput(input_str):\n",
|
27 |
+
" output_str = conversion.predict(input=input_str)\n",
|
28 |
+
" return output_str\n",
|
29 |
+
"\n",
|
30 |
+
"demo = gr.Interface(\n",
|
31 |
+
" fn=takeinput,\n",
|
32 |
+
" inputs=[\"text\"],\n",
|
33 |
+
" outputs=[\"text\"]\n",
|
34 |
+
")\n",
|
35 |
+
"\n",
|
36 |
+
"demo.launch(share=True)\n"
|
37 |
+
]
|
38 |
+
},
|
39 |
+
{
|
40 |
+
"cell_type": "code",
|
41 |
+
"execution_count": null,
|
42 |
+
"metadata": {},
|
43 |
+
"outputs": [],
|
44 |
+
"source": []
|
45 |
+
}
|
46 |
+
],
|
47 |
+
"metadata": {
|
48 |
+
"language_info": {
|
49 |
+
"name": "python"
|
50 |
+
},
|
51 |
+
"orig_nbformat": 4
|
52 |
+
},
|
53 |
+
"nbformat": 4,
|
54 |
+
"nbformat_minor": 2
|
55 |
+
}
|
README.md
CHANGED
@@ -1,12 +1,6 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
|
4 |
-
colorFrom: blue
|
5 |
-
colorTo: blue
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.46.0
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
---
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: Gradio_Langchain_Simple_UI
|
3 |
+
app_file: langchain-app.ipynb
|
|
|
|
|
4 |
sdk: gradio
|
5 |
sdk_version: 3.46.0
|
|
|
|
|
6 |
---
|
|
|
|
langchain-app.ipynb
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [
|
8 |
+
{
|
9 |
+
"name": "stdout",
|
10 |
+
"output_type": "stream",
|
11 |
+
"text": [
|
12 |
+
"Running on local URL: http://127.0.0.1:7863\n",
|
13 |
+
"Running on public URL: https://cf43e4871c9bab7308.gradio.live\n",
|
14 |
+
"\n",
|
15 |
+
"This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n"
|
16 |
+
]
|
17 |
+
},
|
18 |
+
{
|
19 |
+
"data": {
|
20 |
+
"text/html": [
|
21 |
+
"<div><iframe src=\"https://cf43e4871c9bab7308.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
22 |
+
],
|
23 |
+
"text/plain": [
|
24 |
+
"<IPython.core.display.HTML object>"
|
25 |
+
]
|
26 |
+
},
|
27 |
+
"metadata": {},
|
28 |
+
"output_type": "display_data"
|
29 |
+
},
|
30 |
+
{
|
31 |
+
"data": {
|
32 |
+
"text/plain": []
|
33 |
+
},
|
34 |
+
"execution_count": 1,
|
35 |
+
"metadata": {},
|
36 |
+
"output_type": "execute_result"
|
37 |
+
}
|
38 |
+
],
|
39 |
+
"source": [
|
40 |
+
"import os\n",
|
41 |
+
"import gradio as gr\n",
|
42 |
+
"from dotenv import load_dotenv, find_dotenv\n",
|
43 |
+
"_ = load_dotenv(find_dotenv())\n",
|
44 |
+
"\n",
|
45 |
+
"from langchain.chains import ConversationChain\n",
|
46 |
+
"from langchain.chat_models import ChatOpenAI\n",
|
47 |
+
"from langchain.memory import ConversationBufferMemory\n",
|
48 |
+
"\n",
|
49 |
+
"llm = ChatOpenAI(temperature=0.0)\n",
|
50 |
+
"memory = ConversationBufferMemory()\n",
|
51 |
+
"conversion = ConversationChain(\n",
|
52 |
+
" llm=llm,\n",
|
53 |
+
" memory=memory,\n",
|
54 |
+
" verbose=False\n",
|
55 |
+
")\n",
|
56 |
+
"\n",
|
57 |
+
"def takeinput(input_str):\n",
|
58 |
+
" output_str = conversion.predict(input=input_str)\n",
|
59 |
+
" return output_str\n",
|
60 |
+
"\n",
|
61 |
+
"demo = gr.Interface(\n",
|
62 |
+
" fn=takeinput,\n",
|
63 |
+
" inputs=[\"text\"],\n",
|
64 |
+
" outputs=[\"text\"]\n",
|
65 |
+
")\n",
|
66 |
+
"\n",
|
67 |
+
"demo.launch(share=True)\n"
|
68 |
+
]
|
69 |
+
},
|
70 |
+
{
|
71 |
+
"cell_type": "code",
|
72 |
+
"execution_count": null,
|
73 |
+
"metadata": {},
|
74 |
+
"outputs": [],
|
75 |
+
"source": []
|
76 |
+
}
|
77 |
+
],
|
78 |
+
"metadata": {
|
79 |
+
"kernelspec": {
|
80 |
+
"display_name": "Python 3 (ipykernel)",
|
81 |
+
"language": "python",
|
82 |
+
"name": "python3"
|
83 |
+
},
|
84 |
+
"language_info": {
|
85 |
+
"codemirror_mode": {
|
86 |
+
"name": "ipython",
|
87 |
+
"version": 3
|
88 |
+
},
|
89 |
+
"file_extension": ".py",
|
90 |
+
"mimetype": "text/x-python",
|
91 |
+
"name": "python",
|
92 |
+
"nbconvert_exporter": "python",
|
93 |
+
"pygments_lexer": "ipython3",
|
94 |
+
"version": "3.11.4"
|
95 |
+
}
|
96 |
+
},
|
97 |
+
"nbformat": 4,
|
98 |
+
"nbformat_minor": 4
|
99 |
+
}
|