Skip to content

Conversation

@avinash2692
Copy link
Contributor

@avinash2692 avinash2692 commented Oct 29, 2025

Make generate_from_raw public in all backends. Fixes #208

TODOs:

  • Change the base class
  • Refactor openai backend
    • Refactor class
    • Refactor tests
  • Refactor ollama backend
    • Refactor class
    • Refactor tests
  • Refactor litellm backend
    • Refactor class
    • Refactor tests
  • Refactor hf backend
    • Refactor class
    • Refactor tests

@mergify
Copy link

mergify bot commented Oct 29, 2025

Merge Protections

Your pull request matches the following merge protections and will not be merged until they are valid.

🟢 Enforce conventional commit

Wonderful, this rule succeeded.

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert|release)(?:\(.+\))?:

@avinash2692 avinash2692 marked this pull request as ready for review October 30, 2025 00:03
Copy link
Contributor

@jakelorocco jakelorocco left a comment

Choose a reason for hiding this comment

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

The vLLM backend was just merged. Could you please make sure that it conforms to the changes outlined here?

Also, test are failing, it looks like we may be hitting some time limit.

def generate_from_raw(
self,
actions: list[Component | CBlock],
ctx: Context,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand why we are passing in a context if we are not using it. I think we should just leave it out of the function definition if we aren't going to use it for generation or append to it after the generation. I see that the docstring documents that it's not used, but I think that just adds extra confusion.

It was also my impression from the team meeting yesterday that we don't have a clear idea going forward of what we want context to eventually do here.

I think the one reason for keeping it would be to eventually utilize it. However, that is functionally an api change if we were to change the behavior of context. As a result, I think it would make sense to just break the function def in that instance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree we should remove both tools and ctx, but only kept it in cause in the original issue, the motivation was to keep the signature consistent with generate_from_context.

mot._generate_log = generate_log

def _generate_from_raw(
def generate_from_raw(
Copy link
Contributor

Choose a reason for hiding this comment

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

This implementation of generate_from_raw continues the current implementation's decision to be synchronous. Are we okay with not allowing async batching operations (and it might be the case that these batching interfaces don't support async, I haven't looked)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think support of async is inconsistent here. Given that generate_from_raw is based on the /competitions endpoint which is deprecated, I think its going to be hard to maintain that for all backends here.

Comment on lines 487 to 488
"""Generate using the completions api. Gives the input provided to the model without templating."""
raise NotImplementedError("This method is not implemented yet.")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think if we are promoting this to be a supported API, we should add support for LiteLLM.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair, but I might make a separate PR for this just to unblock this issue

Comment on lines +706 to +712
output._meta = {
"oai_completion_response": response.model_dump(),
"usage": completion_response.usage.model_dump()
if completion_response.usage
else None,
}

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like LiteLLM has standardized on:

  "usage": {
    "prompt_tokens": 18,
    "completion_tokens": 25,
    "total_tokens": 43
  }

Even if OpenAI doesn't give us back correct values, it might still be worthwhile to standardize these fields in ModelOutputThunks and just not set them for OpenAI. Otherwise, anyone that has to use these values needs to be aware of every backend (instead of just checking if the values are None).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is similar to what openai returns. I think it should be part of the .usage object.

Copy link
Contributor

@jakelorocco jakelorocco left a comment

Choose a reason for hiding this comment

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

approving; I think litellm needs to eventually be supported and I think the "usage" values that are being stored in meta ought to be moved to standardized fields in the ModelOutputThunk

@avinash2692 avinash2692 merged commit 7eae224 into main Nov 3, 2025
4 checks passed
@avinash2692 avinash2692 deleted the feat-208-public-generate-raw branch November 3, 2025 19:46
tuliocoppola pushed a commit to tuliocoppola/mellea that referenced this pull request Nov 5, 2025
* feat: making generate_from_raw public in openai

* feat: making generate_from_raw public in ollama

* feat: making generate_from_raw public in ollama

* feat: making generate_from_raw public in hf, watsonx

* feat: making generate_from_raw public in vllm

* adding warning to hf backend

* attempt at standardizing usage metrics
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.

Promote _generate_from_raw to public

3 participants