This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import TypedDict, List | |
import colorama | |
import os | |
from langchain_openai import ChatOpenAI | |
from langchain_core.messages import SystemMessage | |
from langchain_core.messages import HumanMessage | |
from langchain_core.runnables import RunnableConfig | |
from langgraph.graph import StateGraph, END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from langchain.text_splitter import RecursiveCharacterTextSplitter | |
from langchain_community.document_loaders import WebBaseLoader | |
from langchain_community.vectorstores import Chroma | |
from langchain_community.embeddings.sentence_transformer import SentenceTransformerEmbeddings | |
from typing import Annotated, Dict, TypedDict | |
from langchain_core.messages import BaseMessage | |
import json | |
import operator | |
from typing import Annotated, Sequence, TypedDict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gradio as gr | |
from langchain.embeddings.openai import OpenAIEmbeddings | |
from langchain.text_splitter import CharacterTextSplitter | |
from langchain.vectorstores import Chroma | |
from langchain.chains import ConversationalRetrievalChain | |
from langchain.chat_models import ChatOpenAI | |
from langchain.document_loaders import PyPDFLoader | |
import os |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gradio as gr | |
def sketch_recognition(img): | |
pass# Implement your sketch recognition model here... | |
gr.Interface(fn=sketch_recognition, inputs="sketchpad", outputs="label").launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gradio as gr | |
def greet(name): | |
return"Hello " + name + "!" | |
with gr.Blocks() as demo: | |
name = gr.Textbox(label="Name") | |
output = gr.Textbox(label="Output Box") | |
greet_btn = gr.Button("Greet") | |
greet_btn.click(fn=greet, inputs=name, outputs=output, api_name="greet") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#API_ENDPOINT = "https://api.openai.com/v1/chat/completions" | |
# Note: you need to be using OpenAI Python v0.27.0 for the code below to work | |
import openai | |
openai.ChatCompletion.create( | |
model="gpt-3.5-turbo", | |
messages=[ | |
{"role": "system", "content": "You are a helpful assistant."}, | |
{"role": "user", "content": "Who won the world series in 2020?"}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
'id': 'chatcmpl-6p9XYPYSTTRi0xEviKjjilqrWU2Ve', | |
'object': 'chat.completion', | |
'created': 1677649420, | |
'model': 'gpt-3.5-turbo', | |
'usage': {'prompt_tokens': 56, 'completion_tokens': 31, 'total_tokens': 87}, | |
'choices': [ | |
{ | |
'message': { | |
'role': 'assistant', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with gr.Row(): | |
with gr.Column(scale=0.85): | |
txt = gr.Textbox( | |
show_label=False, | |
placeholder="Enter text and press enter", | |
).style(container=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with gr.Blocks() as demo: | |
radio = gr.Radio(value='gpt-3.5-turbo', choices=['gpt-3.5-turbo','gpt-4'], label='models') | |
chatbot = gr.Chatbot(value=[], elem_id="chatbot").style(height=650) | |
with gr.Row(): | |
with gr.Column(scale=0.90): | |
txt = gr.Textbox( | |
show_label=False, | |
placeholder="Enter text and press enter, or upload an image", |
NewerOlder