File size: 1,311 Bytes
5a813b2
 
 
 
 
 
 
 
 
 
1cc6fa9
5a813b2
 
 
1cc6fa9
5a813b2
1cc6fa9
5a813b2
1cc6fa9
 
 
 
8c6351b
5a813b2
1cc6fa9
5a813b2
 
1cc6fa9
 
8c6351b
 
1cc6fa9
8c6351b
1cc6fa9
8c6351b
1cc6fa9
8c6351b
1cc6fa9
 
8c6351b
1cc6fa9
 
5a813b2
8c6351b
 
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
import base64
import cv2
import openai
from dotenv import load_dotenv
from langchain.prompts import ChatPromptTemplate, MessagesPlaceholder
from langchain.schema.messages import SystemMessage
from langchain_community.chat_message_histories import ChatMessageHistory
from langchain_core.output_parsers import StrOutputParser
from langchain_core.runnables.history import RunnableWithMessageHistory
from langchain_openai import ChatOpenAI
import streamlit as st

load_dotenv()

class VideoStream:
    def __init__(self):
        self.cap = cv2.VideoCapture(0)

    def get_frame(self):
        ret, frame = self.cap.read()
        encoded_image = cv2.imencode('.jpg', frame)[1].tobytes()
        return encoded_image

class Assistant:
    # ... (Same code as before for the Assistant class)

def main():
    st.title("AI Assistant App")
    video_stream = VideoStream()

    # model = ChatGoogleGenerativeAI(model="gemini-1.5-flash-latest")
    model = ChatOpenAI(model="gpt-4o")  # Using OpenAI's GPT-4 model

    assistant = Assistant(model)

    if st.button("Start"):
        while True:
            frame = video_stream.get_frame()
            st.image(frame, channels="BGR")

            # Add code to capture audio input and process the response here
            # ...

if __name__ == "__main__":
    main()