Spaces:
Sleeping
Sleeping
Delete textgen.py
Browse files- textgen.py +0 -51
textgen.py
DELETED
@@ -1,51 +0,0 @@
|
|
1 |
-
from dotenv import load_dotenv
|
2 |
-
|
3 |
-
load_dotenv() # take environment variables from .env.
|
4 |
-
|
5 |
-
import streamlit as st
|
6 |
-
import os
|
7 |
-
import pathlib
|
8 |
-
import textwrap
|
9 |
-
|
10 |
-
import google.generativeai as genai
|
11 |
-
|
12 |
-
from IPython.display import display
|
13 |
-
from IPython.display import Markdown
|
14 |
-
|
15 |
-
|
16 |
-
def to_markdown(text):
|
17 |
-
text = text.replace('•', ' *')
|
18 |
-
return Markdown(textwrap.indent(text, '> ', predicate=lambda _: True))
|
19 |
-
|
20 |
-
os.getenv("GOOGLE_API_KEY")
|
21 |
-
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
22 |
-
|
23 |
-
## Function to load OpenAI model and get respones
|
24 |
-
|
25 |
-
def get_gemini_response(question):
|
26 |
-
model = genai.GenerativeModel('gemini-1.5-flash')
|
27 |
-
response = model.generate_content(question)
|
28 |
-
return response.text
|
29 |
-
|
30 |
-
##initialize our streamlit app
|
31 |
-
|
32 |
-
# UI improvements
|
33 |
-
st.set_page_config(
|
34 |
-
page_title="Ask Gemini!",
|
35 |
-
layout="wide", # Wider layout for better use of space
|
36 |
-
initial_sidebar_state="collapsed", # Hide sidebar initially
|
37 |
-
)
|
38 |
-
|
39 |
-
st.title("Talk to Gemini") # Clear and descriptive title
|
40 |
-
|
41 |
-
user_input = st.text_input(
|
42 |
-
"Ask your question:", key="user_input", placeholder="Type your question here..."
|
43 |
-
) # Descriptive placeholder text
|
44 |
-
|
45 |
-
if user_input:
|
46 |
-
st.subheader("Gemini's Response:")
|
47 |
-
response = get_gemini_response(user_input)
|
48 |
-
st.write(response)
|
49 |
-
st.success("Got your response! Ask another question or refresh the page for a new start.")
|
50 |
-
else:
|
51 |
-
st.info("Start a conversation by entering your question in the box above.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|