Update TextGen/router.py
Browse files123345610 unmodified lines171819202122232425262728293031323334353637383940 unmodified lines8081826667838485866970878889909192939495969798import osimport timefrom pydantic import BaseModelfrom langchain_core.pydantic_v1 import BaseModel, Fieldfrom fastapi import FastAPI, HTTPException, Query, Requestfrom fastapi.responses import FileResponsefrom fastapi.middleware.cors import CORSMiddleware10 unmodified linesfrom gradio_client import Clientfrom typing import List
class PlayLastMusic(BaseModel): '''plays the lastest created music ''' Desicion: str = Field( ..., description="Yes or No" )class CreateLyrics(BaseModel): f'''create some Lyrics for a new music''' Desicion: str = Field( ..., description="Yes or No" )class CreateNewMusic(BaseModel): f'''create a new music with the Lyrics previously computed''' Name: str = Field( ..., description="tags to describe the new music" )
class Message(BaseModel): npc: str | None = None messages: List[str] | None = None40 unmodified lines print(new_messages) # Initialize the LLM llm = ChatGoogleGenerativeAI( model="gemini-pro", max_output_tokens=100, model="gemini-1.5-pro-latest", max_output_tokens=300, temperature=1, safety_settings={ HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_NONE, }, HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT: HarmBlockThreshold.BLOCK_NONE, HarmCategory.HARM_CATEGORY_HARASSMENT: HarmBlockThreshold.BLOCK_NONE, HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_NONE, HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT: HarmBlockThreshold.BLOCK_NONE }, ) if npc=="bard": llm = llm.bind_tools([PlayLastMusic,CreateNewMusic,CreateLyrics])
llm_response = llm.invoke(new_messages) print(llm_response) return Generate(text=llm_response.content)TextGen/router.py+29-5