-
Notifications
You must be signed in to change notification settings - Fork 65
Improve ChainedLLM to handle when to move to next llm in chain, add r… #1354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…etries to Gemini, remove retries from VLMTableStructureExtractor
If you're OK with the approach taken here, I can add some tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check the async thing. Otherwise looks fine.
return d | ||
|
||
@staticmethod | ||
def extract_table_block(html_str: str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a concrete problem with this, but another option might be to use BeautifulSoup, which we should already have as a dependency. It theoretically handles "broken" HTML, and might theoretically be able to recover from other kinds of issues. Not a big priority.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switched to using BeautifulSoup.
def __init__( | ||
self, | ||
chain: list[LLM], | ||
response_checker: Optional[Callable[[str], bool]] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. let's start with this. I'd love to get to the point where we can have a library of "validators" that can be used with LLM calls.
lib/sycamore/sycamore/llms/gemini.py
Outdated
timeout=120.0, | ||
) | ||
async def generate_content_async(self, model, contents, config): | ||
return self._client.models.generate_content(model=model, contents=contents, config=config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this need to be self._client.aio.models.generate_content
or need an await?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes! I'll add 'await'.
if res.startswith("```html"): | ||
res = res[7:].rstrip("`") | ||
res = res.strip() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thought is that you could have the html checker handle this as well, since it's pretty common for llms to use the backtick thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if we want the response check to modify the response. Also, it's only used when the LLM is a ChainedLLM so we still need this code for non-chained LLMs.
…etries to Gemini, remove retries from VLMTableStructureExtractor