AlanFeder's picture
Update app.py
0b44a42 verified
import os
from all_rag_fns import do_rag
import gradio as gr
def gr_ch_if(user_input: str, history):
oai_api_key = os.getenv("OPENAI_API_KEY")
response, _ = do_rag(
user_input,
stream=False,
n_results=3,
model_name="gpt-4o-mini",
oai_api_key=oai_api_key,
)
return response
with gr.Blocks() as demo:
gr.ChatInterface(
fn=gr_ch_if,
title="Use Gradio to Run RAG on the previous R/Gov Talks - Chat Interface 1",
)
# Add the static markdown at the bottom
gr.Markdown(
"""This Gradio app was created for Alan Feder's [talk at the 2024 R/Gov Conference](https://rstats.ai/gov.html). \n\n The Github repository that houses all the code is [here](https://github.com/AlanFeder/rgov-2024) -- feel free to fork it and use it on your own!"""
)
gr.Markdown("***")
gr.Markdown("### Contact me!")
gr.Image("https://github.com/AlanFeder/rgov-2024/blob/main/AJF_Headshot.jpg?raw=true", width=40, show_share_button=False, show_fullscreen_button=False, show_download_button=False, show_label=False)
gr.Markdown(
"""[Email](mailto:[email protected]) | [Website](https://www.alanfeder.com/) | [LinkedIn](https://www.linkedin.com/in/alanfeder/) | [GitHub](https://github.com/AlanFeder)"""
)
if __name__ == "__main__":
demo.launch(
favicon_path="https://raw.githubusercontent.com/AlanFeder/rgov-2024/refs/heads/main/favicon_io/favicon.ico",
)