Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files- README.md +2 -8
- langchain-app.py +28 -0
README.md
CHANGED
@@ -1,12 +1,6 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
|
4 |
-
colorFrom: indigo
|
5 |
-
colorTo: yellow
|
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: Langchain_Simple_Gradio_App
|
3 |
+
app_file: langchain-app.py
|
|
|
|
|
4 |
sdk: gradio
|
5 |
sdk_version: 3.46.0
|
|
|
|
|
6 |
---
|
|
|
|
langchain-app.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from dotenv import load_dotenv, find_dotenv
|
4 |
+
_ = load_dotenv(find_dotenv())
|
5 |
+
|
6 |
+
from langchain.chains import ConversationChain
|
7 |
+
from langchain.chat_models import ChatOpenAI
|
8 |
+
from langchain.memory import ConversationBufferMemory
|
9 |
+
|
10 |
+
llm = ChatOpenAI(temperature=0.0)
|
11 |
+
memory = ConversationBufferMemory()
|
12 |
+
conversion = ConversationChain(
|
13 |
+
llm=llm,
|
14 |
+
memory=memory,
|
15 |
+
verbose=False
|
16 |
+
)
|
17 |
+
|
18 |
+
def takeinput(name):
|
19 |
+
output_str = conversion.predict(input=name)
|
20 |
+
return output_str
|
21 |
+
|
22 |
+
demo = gr.Interface(
|
23 |
+
fn=takeinput,
|
24 |
+
inputs=["text"],
|
25 |
+
outputs=["text"]
|
26 |
+
)
|
27 |
+
|
28 |
+
demo.launch(share=True)
|