Skip to content
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

[Feat] Add xAI grok-beta to code #858

Merged
merged 8 commits into from
Nov 7, 2024
Merged

[Feat] Add xAI grok-beta to code #858

merged 8 commits into from
Nov 7, 2024

Conversation

lingyielia
Copy link
Contributor

@lingyielia lingyielia commented Nov 7, 2024

Description

xAI is not officially supported by Langchain yet. But it can just piggyback ChatOpenAI.

This might be slightly confusing when using in Jupyter notebook.
In UI it's simple.

Screenshot

Screenshot 2024-11-07 at 11 17 44

Notice

  • I acknowledge and agree that, by checking this box and clicking "Submit Pull Request":

    • I submit this contribution under the Apache 2.0 license and represent that I am entitled to do so on behalf of myself, my employer, or relevant third parties, as applicable.
    • I certify that (a) this contribution is my original creation and / or (b) to the extent it is not my original creation, I am authorized to submit this contribution on behalf of the original creator(s) or their licensees.
    • I certify that the use of this contribution as authorized by the Apache 2.0 license does not violate the intellectual property rights of anyone else.
    • I have not referenced individuals, products or companies in any commits, directly or indirectly.
    • I have not added data or restricted code in any commits, directly or indirectly.

@github-actions github-actions bot added the Vizro-AI 🤖 Issue/PR that addresses Vizro-AI package label Nov 7, 2024
@lingyielia lingyielia merged commit 1dee965 into main Nov 7, 2024
38 checks passed
@lingyielia lingyielia deleted the test/xai branch November 7, 2024 20:02
@@ -93,11 +93,18 @@ class ChartPlan(BaseModel):

@validator("chart_code")
def _check_chart_code(cls, v):
# Remove markdown code block if present
Copy link
Contributor

Choose a reason for hiding this comment

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

ChatGPT just suggested me this:

import re

def strip_markdown(v):
    # Strip leading and trailing markdown code block delimiters if they exist
    return re.sub(r"^```(?:python\n)?|```$", "", v).strip()

or

def strip_markdown(v):
    if v.startswith("```python\n"):
        v = v[len("```python\n"):]
    elif v.startswith("```\n"):
        v = v[len("```\n"):]
    if v.endswith("```"):
        v = v[:-3]
    return v.strip()

Maybe better?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Vizro-AI 🤖 Issue/PR that addresses Vizro-AI package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants