Skip to content

TTYG-166 Configurable LLM#50

Open
pgan002 wants to merge 42 commits intomainfrom
TTYG-166
Open

TTYG-166 Configurable LLM#50
pgan002 wants to merge 42 commits intomainfrom
TTYG-166

Conversation

@pgan002
Copy link
Collaborator

@pgan002 pgan002 commented Feb 7, 2026

Modify the configuration file to specify LLM details using the litellm library. If parameter config_file_path is not specified or the file does not contain the key llm, the metrics that require an LLM are skipped.

We change the code to receive LLM parameters from the top-level function.

@pgan002 pgan002 self-assigned this Feb 7, 2026
from pydantic import BaseModel, Field, model_validator

from . import custom_evaluation
from . import llm as llm_
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we rename llm to llm_?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise defining class Config field llm gives error 'Type of "llm" could not be determined because it refers to itself'.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest then to rename the field llm in the Config class to llm_config or something. I don't like the underscore. The readability is not good.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like llm_config. Renamed the imported class instead.

class Config(BaseModel):
name: str
temperature: float = Field(ge=0.0, le=1.0)
max_tokens: int = Field(ge=1)
Copy link
Collaborator

@nelly-hateva nelly-hateva Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we merge #47 first, this should be removed, right? Also, we should introduce an embeddings model for answer relevancy, right https://github.com/Ontotext-AD/graphrag-eval/pull/47/changes#diff-f3dd3002658ae3670117b3df5ee6937158b2fad7c1543420fc25ccae901bfe24R9 ?

Copy link
Collaborator Author

@pgan002 pgan002 Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course! After one of these PRs is merged, the other has to be rebased and re-reviewed. Feel free to pause reviewing one of these until the other is merged and rebased.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still have this field. What is the purpose of it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See section Configuration: "maximum number of tokens to generate"

def call(config: Config, prompt: str) -> str:
import litellm
try:
response = litellm.completions(
Copy link
Collaborator

@nelly-hateva nelly-hateva Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My IDE is complaining that it can't find reference to this function

Image

so I can't click on it and inspect the parameters. What I wonder is if for example I want to use Azure OpenAI how can I pass the API version? I know Azure requires some additional params, which I don't see how to pass.

Copy link
Collaborator Author

@pgan002 pgan002 Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you poetry install --with llm?

Now linked LiteLLM documentation from the description.

It seems that there are many optional params that differ between agent/model types and providers. For providers whose name starts with either 'A' or 'B', I found:

  • temperature
  • top_p
  • api_base
  • api_version
  • reasoning_effort
  • reasoning
  • verbosity
  • tools
  • tool_choice
  • max_output_tokens
  • response_format
  • enforce_validation
  • thinking
  • vertex_project
  • vertex_location
  • vertex_credentials
  • use_psc_endpoint_format
  • extra_headers
  • parallel_tool_calls
  • aws_access_key_id
  • aws_secret_access_key
  • aws_session_name
  • aws_session_token
  • aws_region_name
  • aws_profile_name
  • aws_role_name
  • aws_web_identity_token
  • aws_bedrock_runtime_endpoint
  • api_key
  • max_tokens

I modified the PR to expect name, temperature and max_tokens and use where them when appropriate, and pass all params to litellm.completions().

Copy link
Collaborator

@nelly-hateva nelly-hateva Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I did poetry install --with llm, but I still see this warning. I also see a warning that .dict() is deprectated

Image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My IDE is complaining that it can't find reference to this function
Good catch: it's completion().

warning that .dict() is deprectated
Changed to .model_dump().

@pgan002 pgan002 requested a review from Aleksis99 February 12, 2026 01:14
README.md Outdated
* `temperature`: (float in the range [0.0, 2.0]) adversarial temperature for generation
* `max_tokens`: (int > 0) maximum number of tokens to generate
* Optional keys: parameters to be passed to LiteLLM for generation (for (`answer_correctness`)[#output-keys] and (custom evaluation)[#custom-evaluation-(custom-metrics)])
* `embedding`: required for (`answer_relevance`)[#output-keys].
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the link is not rendered as one

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

README.md Outdated
* `embedding`: required for (`answer_relevance`)[#output-keys].
* `provider`: (str) name of the organiation providing the embedding model
* `model`: (str) name of the embedding model
* `custom_evaluations`: (list of the following maps) required nonempty for (custom evaluation)[#custom-evaluation-(custom-metrics)]. Each map has keys:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the link is not rendered as one

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

README.md Outdated

#### Example Configuration File With LLM Configuration

Below is a YAML file that configures the LLM generation ((for metrics that require an LLM)[#llm-use-in-evaluation]) and embedding (for (answer relevance)[#otuput-keys]).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the links are not rendered as such

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@nelly-hateva
Copy link
Collaborator

nelly-hateva commented Feb 23, 2026

  • There is a typo in the PR description - detais
  • The title can be improved to something like Implement the ability for the user to define, which LLM to use using the litellm library

@pgan002 pgan002 force-pushed the TTYG-166 branch 2 times, most recently from 8b05abe to caf2862 Compare February 24, 2026 08:37
@pgan002 pgan002 changed the title TTYG-166 Configure LLMs TTYG-166 Configurable LLM Feb 24, 2026
@pgan002 pgan002 force-pushed the TTYG-166 branch 2 times, most recently from cef58eb to 746fa65 Compare February 24, 2026 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants