File size: 1,034 Bytes
6d465bb
81cf284
 
1269bc4
 
86a33c4
 
 
 
81cf284
 
 
86a33c4
 
 
 
 
 
 
81cf284
 
86a33c4
 
81cf284
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import keyfile 
import streamlit as st
from langchain_openai import OpenAI
import getpass
import os
import google.generativeai as genai


genai.configure(api_key=keyfile.GEMINI_API_KEY)

# Creating a function for getting the responses from OpenAI
def get_response(question):
    # os.environ["OPENAI_API_KEY"] = keyfile.OPENAI_API_KEY
    # llm = OpenAI()
    # answer = llm.invoke(question)
    # return answer
    model = genai.GenerativeModel("gemini-1.5-flash")
    response = model.generate_content("Write a story about a magic backpack.")
    return response.text

# Using Streamlit for generation of page
st.set_page_config(page_title = "ASK GPT / GEMINI", page_icon = ":robot:")
st.header("ASK GPT / GEMINI Application")

# Create a function for taking user input
def get_user_input():
    text = st.text_input("Ask: ", key = "input")
    return text

user_input = get_user_input()
resp = get_response(user_input)

# Submission button
submit = st.button("Ask!")

if submit:
    st.subheader("Answer: ")
    st.write(resp)