reshav1 commited on
Commit
5813654
1 Parent(s): e514a32

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -24
app.py CHANGED
@@ -1,30 +1,31 @@
1
- import streamlit
2
- import langchain
3
- from langchain.llms import GenerativeModel
4
 
5
- # Replace with your Gemini API key
6
- API_KEY = ""
7
 
8
- # Configure the model
9
- llm = GenerativeModel("google-llm/text-davinci-003", api_key=API_KEY)
10
 
11
- def generate_response(user_input):
12
- """
13
- Sends user input to Gemini and returns its response.
14
 
15
- Args:
16
- user_input: The user's message.
 
 
 
 
17
 
18
- Returns:
19
- The generated response from Gemini.
20
- """
21
- prompt ={user_input}
22
- response = llm.generate_content(prompt=prompt)
23
- return response.content[0]["text"]
 
 
 
 
 
24
 
25
- while True:
26
- user_input = input("enter your text")
27
- if user_input.lower() == "quit":
28
- break
29
- response = generate_response(user_input)
30
- st.write( {response})
 
1
+ import gradio
2
+ from transformers import pipeline
 
3
 
4
+ # Initialize the Hugging Face model
5
+ model = pipeline(model='google/flan-t5-large')
6
 
 
 
7
 
8
+ # Define the chatbot function
9
+ def chatbot(input_text):
 
10
 
11
+ prompt = f"Give the answer of the given input in context from the bhagwat geeta. give suggestions to user which are based upon the meanings of shlok in bhagwat geeta, input = {input_text}"
12
+ # Generate a response from the Hugging Face model
13
+ response = model(prompt, max_length=250, do_sample=True)[0]['generated_text'].strip()
14
+
15
+ # Return the bot response
16
+ return response
17
 
18
+ # Define the Gradio interface
19
+ gradio_interface = gradio.Interface(
20
+ fn=chatbot,
21
+ inputs='text',
22
+ outputs='text',
23
+ title='Chatbot',
24
+ description='A weird chatbot conversations experience.',
25
+ examples=[
26
+ ['Hi, how are you?']
27
+ ]
28
+ )
29
 
30
+ # Launch the Gradio interface
31
+ gradio_interface.launch()