-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
56 lines (39 loc) · 1.35 KB
/
app.py
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import base64
import pandas as pd
import streamlit as st
from langchain.embeddings.fastembed import FastEmbedEmbeddings
from langchain.vectorstores import Chroma
from langchain.document_loaders import DataFrameLoader
from langchain.schema.runnable import RunnablePassthrough
from langchain.schema import StrOutputParser
from langchain.prompts import PromptTemplate
from utils import format_as_doc, format_docs, llm
# Load the dataset from the data folder
@st.cache_data
def load_data(url="https://storage.googleapis.com/swe-workshop-23/organizations.json"):
# TODO: load the data from the url
pass
@st.cache_resource
def vectorize_data(df):
# TODO: vectorize the data
pass
# TODO: provide a prompt template
prompt = PromptTemplate.from_template("")
df = load_data()
docsearch = vectorize_data(df)
retriever = docsearch.as_retriever(search_kwargs={"k": 3})
chain = (
# TODO: create the chain
)
# Create a Streamlit app
st.title("Interests-based Prompt Generator")
# Create a text input field
user_interests = st.text_input("Enter your interests")
# Create a button
if st.button("Submit"):
# Indicate the response is loading
with st.spinner("Generating response..."):
# Call the language model with the user's input
response = chain.invoke(user_interests)
st.write(response)
# TODO: bonus! add the organization's logo