Skip to content

Commit

Permalink
tutorial73
Browse files Browse the repository at this point in the history
  • Loading branch information
ronidas39 committed Jun 1, 2024
1 parent 343917f commit 70b1382
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 0 deletions.
Binary file modified tutorial72/chroma_db_oai/chroma.sqlite3
Binary file not shown.
Binary file added tutorial73/Screenshot 2024-06-01 114615.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions tutorial73/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import streamlit as st
from langchain_openai import ChatOpenAI
import base64
from PIL import Image
from langchain.schema.messages import HumanMessage,AIMessage
llm=ChatOpenAI(model="gpt-4o",max_tokens=2048)

def encode_image(upload_file):
image_bytes=upload_file.getvalue()
base64_image=base64.b64encode(image_bytes).decode("utf-8")
return base64_image


def get_response(b64image):
msg=llm.invoke(
[
AIMessage(
content="""
you are intelligent assistant who can solve any mathematical problems on derivatives,
you will be shared with a image where each line contains a problem ,
your task will be to solve all of them with possible explanation and step by step solutions
and formulas , then create a complete answer book
"""
),
HumanMessage(
content=[
{"type":"image_url",
"image_url":{
"url":"data:image/jpg;base64, " + b64image,
"detail":"auto"
}
}
]
)
]
)
content=msg.content
content=content.replace("\\","")
return content




def main():
st.title="Student Assignment Solver"
upload_file=st.file_uploader("upload your assignment:",type=["jpg","png"])
if upload_file is not None:
image=Image.open(upload_file)
st.image(image,caption="your assignment",use_column_width=True)
st.text("your assignment uploaded successfully")
base64_image=encode_image(upload_file)
btn=st.button("submit")
if btn:
response=get_response(base64_image)
print(response)
st.markdown(response,unsafe_allow_html=True)


if __name__=="__main__":
main()



6 changes: 6 additions & 0 deletions tutorial73/prompt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""
you are intelligent assistant who can solve any mathematical problems on derivatives,
you will be shared with a image where each line contains a problem ,
your task will be solve all of them with possible explanation and step by step solutions
and formulas , then crate a complete answer book
"""
Binary file added tutorial73/tutorial73.pptx
Binary file not shown.

0 comments on commit 70b1382

Please sign in to comment.