From 13b80c518e8759534ff8debe98ced740997a246c Mon Sep 17 00:00:00 2001 From: milenasrb Date: Wed, 27 Nov 2024 09:34:12 +0100 Subject: [PATCH] fix chat generation --- .../in/www1/hephaestus/chat/message/Message.java | 2 +- server/intelligence-service/app/model.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/chat/message/Message.java b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/chat/message/Message.java index 6c2bed6a..b987620c 100644 --- a/server/application-server/src/main/java/de/tum/in/www1/hephaestus/chat/message/Message.java +++ b/server/application-server/src/main/java/de/tum/in/www1/hephaestus/chat/message/Message.java @@ -28,7 +28,7 @@ public class Message { @Enumerated(EnumType.STRING) private MessageSender sender; - @Lob + @Column(length = Length.LONG16) @NonNull private String content; diff --git a/server/intelligence-service/app/model.py b/server/intelligence-service/app/model.py index 29282f47..10c9f9a7 100644 --- a/server/intelligence-service/app/model.py +++ b/server/intelligence-service/app/model.py @@ -1,6 +1,5 @@ import os from .config import settings -from random import randint from typing import Sequence from typing_extensions import Annotated, TypedDict @@ -25,7 +24,7 @@ def invoke(self, message: str): model = MockChatModel() elif settings.is_openai_available: - model = ChatOpenAI() + model = ChatOpenAI(temperature=1.0) elif settings.is_azure_openai_available: model = AzureChatOpenAI() else: @@ -47,7 +46,9 @@ class State(TypedDict): + "Task 2: Ask the student about the overall progress on the project." + "Task 3: Ask the student about the challenges faced during the sprint referring to what he said about progress." + "Task 4: Ask about the plan for the next sprint." - + "Be polite, friendly and do not let the student drive the conversation to any other topic except for the current project.", + + "Be polite, friendly and do not let the student drive the conversation to any other topic except for the current project." + + "Always perform only one task in one message. Listen to what the student says and refer to it in your next message." + + "Analyse the conversation before and asses which task is to be performed. Give the student a feeling of a real conversation, not just questionaire.", ), MessagesPlaceholder(variable_name="messages"), ] @@ -55,12 +56,12 @@ class State(TypedDict): workflow = StateGraph(state_schema=State) trimmer = trim_messages( - max_tokens=400, + max_tokens=4000, strategy="last", token_counter=model, include_system=True, allow_partial=False, - start_on="system", + start_on="human", ) @@ -80,7 +81,6 @@ def call_model(state: State): def send_message(thread_id: str, input_message: str, state: State): config = {"configurable": {"thread_id": thread_id}} - # append the new human message to the conversation state["messages"] += [HumanMessage(input_message)] output = app.invoke( @@ -89,4 +89,4 @@ def send_message(thread_id: str, input_message: str, state: State): ) state["messages"] += output.get("messages", []) - return {"state": state, "response": output} + return {"state": state, "response": output} \ No newline at end of file