Update prompts

This commit is contained in:
Alex Selimov 2025-08-05 10:18:53 -04:00
parent c228a7298a
commit f17b6721f9
Signed by: aselimov
GPG key ID: 3DDB9C3E023F1F31
4 changed files with 10 additions and 29 deletions

View file

@ -69,24 +69,13 @@ Examples:
default=( default=(
"You are a PR review assistant in charge of software quality control. " "You are a PR review assistant in charge of software quality control. "
"You analyze code changes in the context of the full code base to verify style, " "You analyze code changes in the context of the full code base to verify style, "
"syntax, and functionality. Your response should contain exactly 3 suggestions. " "syntax, and functionality. You respond with suggestions to improve code quality "
"Each suggestion must be in the following format:\n" "You only provide sugestions when you find a flaw in the code otherwise you say that "
"```diff\n" "no issues were found. Each suggestion should reference the old code and the new "
"-<old code>\n" "suggested code."
"+<new code>\n" "Do not provide an analysis of the code and do not summarize suggestions. "
"```\n" "Answer as briefly as possible and return only the suggestions in the requested format "
"Reason: <explanation>\n\n" "with bullet points and no extra text. Provide examples when appropriate."
"Here are two examples of the required format:\n"
"```diff\n"
"-somvr = 2 + 2\n"
"+somevar = 2 + 2\n"
"```\n"
"Reason: somvr is likely a typo, try replacing with somevar\n\n"
"```diff\n"
"-add_two_numbers(\"1\", \"2\")\n"
"+add_two_numbers(1,2)\n"
"```\n"
"Reason: add_two_numbers requires numeric values and does not accept strings"
), ),
help="Base branch to compare against (default: %(default)s)", help="Base branch to compare against (default: %(default)s)",
) )

View file

@ -13,7 +13,7 @@ class OllamaConfig:
base_url: str base_url: str
system_prompt: str system_prompt: str
# TODO: Update this to be a passed in value # TODO: Update this to be a passed in value
temperature: float = field(default=0.7) temperature: float = field(default=0.0)
@dataclass(frozen=True) @dataclass(frozen=True)
@ -30,7 +30,7 @@ def create_ollama_config(
model: str, model: str,
server_url: str, server_url: str,
system_prompt: str, system_prompt: str,
temperature=0.7, temperature=0.0,
embedding_model="nomic-embed-text", embedding_model="nomic-embed-text",
) -> OllamaConfig: ) -> OllamaConfig:
"""Create OllamaConfig with validated parameters.""" """Create OllamaConfig with validated parameters."""

View file

@ -2,7 +2,7 @@ from dataclasses import dataclass
from typing import Any from typing import Any
from langchain_core.messages import BaseMessage from langchain_core.messages import BaseMessage
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import RunnableLambda from langchain_core.runnables import RunnableLambda
from langchain_core.runnables.base import RunnableSerializable from langchain_core.runnables.base import RunnableSerializable
from langchain_core.runnables.passthrough import RunnablePassthrough from langchain_core.runnables.passthrough import RunnablePassthrough
@ -61,7 +61,6 @@ def chat_with_client(
client: ChatClient, client: ChatClient,
message: str, message: str,
retriever: VectorStoreRetriever | None = None, retriever: VectorStoreRetriever | None = None,
session_id: str = "default",
verbose: bool = False, verbose: bool = False,
) -> str: ) -> str:
"""Chat with the client and return the response content.""" """Chat with the client and return the response content."""
@ -72,7 +71,6 @@ def chat_with_client(
response = client.chain.invoke( response = client.chain.invoke(
{"input": message, "context": context}, {"input": message, "context": context},
config={"configurable": {"session_id": session_id}},
) )
return response.content return response.content

View file

@ -55,11 +55,5 @@ def get_suggestions(
def craft_message(diff) -> str: def craft_message(diff) -> str:
return ( return (
"Review the following code changes and make up to three suggestions on "
"how to improve it. If the code is sufficiently simple or accurate then say "
"no suggestions can be found. Important issues you should consider are consistent "
"style, introduction of syntax errors, and potentially breaking changes in "
"interfaces/APIs that aren't properly handled.\n\n"
f"The original code:\n```\n{diff.old_content}\n```\n"
f"The new code:\n```\n{diff.new_content}```" f"The new code:\n```\n{diff.new_content}```"
) )