import streamlit as st
import plotly.graph_objects as go
from openai import OpenAI
import json
#from dotenv import find_dotenv, load_dotenv
#_ : bool = load_dotenv(find_dotenv())
Client : OpenAI = OpenAI()
from openai.types.beta import Assistant
OpenAIApi=st.secrets[“OPENAI_API_KEY”]
#==============================================
st.title(“Muzzamil”)
#Store kiya hai taky jb refresh ho to value dubara sy na mily store k bad sy mily
if “map” not in st.session_state:
st.session_state[“map”] = {
“latitude”:39.949610,
“longitude”:-75.163789,
“zoom”:16,
}
#conservation
if “coversation” not in st.session_state:
st.session_state[“coversation”] =
assistant create and thread and run and store them
if “assistant” not in st.session_state:
st.session_state[“assistant”] = Client.beta.assistants.create(
name= “Travel Agent by Muzzamil” ,
instructions=“You are a Helpull travel assistant that can write and execute code , and has access to digital map to display information”,
model=“gpt-3.5-turbo-1106”,
tools=[ {
“name”: “update_map”,
“description”: “Update map to center on a particular location”,
“parameters”: {
“type”: “object”,
“properties”: {
“longitude”: {
“type”: “number”,
“description”: “Longitude of the location to center the map on”
},
“latitude”: {
“type”: “number”,
“description”: “Latitude of the location to center the map on”
},
“zoom”: {
“type”: “integer”,
“description”: “Zoom level of the map”
}
},
“required”: [“longitude”, “latitude”, “zoom”]
}
},{
“name”: “add_markers”,
“description”: “Add list of markers to the map”,
“parameters”: {
“type”: “object”,
“properties”: {
“longitudes”: {
“type”: “array”,
“items”: {
“type”: “number”
},
“description”: “List of longitude of the location to each marker”
},
“latitudes”: {
“type”: “array”,
“items”: {
“type”: “number”
},
“description”: “List of latitude of the location to each marker”
},
“labels”: {
“type”: “array”,
“items”: {
“type”: “string”
},
“description”: “List of text to display on the location of each marker”
}
},
“required”: [“longitudes”, “latitudes”, “labels”]
}
}
]
)
st.session_state[“thread”] = Client.beta.threads.create()
st.session_state[“run”] = None
with st.sidebar:
st.header(“Debug”)
st.write(st.session_state.to_dict())
#===================================================
#Create Two Colums right and left
left_column, right_column = st.columns(2)
with left_column:
st.subheader(“Conservation”)
with right_column:
fig = go.Figure(go.Scattermapbox())
fig.update_layout(
mapbox=dict(
accesstoken=st.secrets[“MapBox_Access”], # Use the token from secrets.toml
center=go.layout.mapbox.Center(
lat=45,
lon=-73
)
),
margin=dict(l=0, r=0, t=0, b=0)
)
st.plotly_chart(
fig,
config = {“displayModeBar” : False},
use_container_width=True,
key = “plotly”,
)
#Add placeholder
st.chat_input(
placeholder=“Ask your question here”,
key=“input_user_msg”,
)
whats the error?