Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,29 +1,9 @@
|
|
1 |
-
# -*- coding: utf-8 -*-
|
2 |
-
"""ChatBot
|
3 |
-
|
4 |
-
Automatically generated by Colab.
|
5 |
-
|
6 |
-
Original file is located at
|
7 |
-
https://colab.research.google.com/drive/1RCVHRRape7ZBO019qsyrnjz6p0yg50kH
|
8 |
-
"""
|
9 |
-
|
10 |
-
!pip install langchain
|
11 |
-
!pip install langchain-community
|
12 |
-
!pip install openai
|
13 |
-
!pip install gradio
|
14 |
-
!pip install huggingface_hub
|
15 |
-
|
16 |
import os
|
17 |
import gradio as gr
|
18 |
from langchain.chat_models import ChatOpenAI
|
19 |
from langchain import LLMChain, PromptTemplate
|
20 |
from langchain.memory import ConversationBufferMemory
|
21 |
|
22 |
-
"""**How to get Open AI API Key?**
|
23 |
-
- Go to https://platform.openai.com/account/api-keys
|
24 |
-
- Create a new Secret Key
|
25 |
-
- Copy the Secret Key for your use.
|
26 |
-
"""
|
27 |
|
28 |
openai_key = os.environ.get("OPENAI_API_KEY")
|
29 |
|
@@ -38,17 +18,6 @@ prompt = PromptTemplate(
|
|
38 |
|
39 |
memory = ConversationBufferMemory(memory_key="chat_history")
|
40 |
|
41 |
-
"""
|
42 |
-
- Similar to Open AI Mondel we can also use HuggingFace Transformer Models.
|
43 |
-
- Reference links: https://python.langchain.com/docs/integrations/providers/huggingface , https://python.langchain.com/docs/integrations/llms/huggingface_hub.html
|
44 |
-
|
45 |
-
"""
|
46 |
-
|
47 |
-
# from langchain.llms import HuggingFacePipeline
|
48 |
-
# hf = HuggingFacePipeline.from_model_id(
|
49 |
-
# model_id="gpt2",
|
50 |
-
# task="text-generation",)
|
51 |
-
|
52 |
llm_chain = LLMChain(
|
53 |
llm=ChatOpenAI(temperature='0.5', model_name="gpt-3.5-turbo"),
|
54 |
prompt=prompt,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import os
|
2 |
import gradio as gr
|
3 |
from langchain.chat_models import ChatOpenAI
|
4 |
from langchain import LLMChain, PromptTemplate
|
5 |
from langchain.memory import ConversationBufferMemory
|
6 |
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
openai_key = os.environ.get("OPENAI_API_KEY")
|
9 |
|
|
|
18 |
|
19 |
memory = ConversationBufferMemory(memory_key="chat_history")
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
llm_chain = LLMChain(
|
22 |
llm=ChatOpenAI(temperature='0.5', model_name="gpt-3.5-turbo"),
|
23 |
prompt=prompt,
|