This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Standalone script to demonstrate structured output issue with Vercel AI Gateway. | |
This script replicates the functionality of src/ai_news_agent/nodes/summarize_episode.py | |
but uses Vercel AI Gateway with LangChain ChatOpenAI and structured output. | |
Expected to demonstrate that .with_structured_output() doesn't work with Vercel AI Gateway. | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app = FastAPI() | |
class Numbers(BaseModel): | |
numbers: List[float] | |
@app.post("/sum/") | |
async def sum_payload(nums: Numbers) -> JSONResponse: | |
"""Sum a list of numbers.""" | |
result = sum(nums.numbers) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"public_identifier": "ericnessdata", | |
"profile_pic_url": "https://s3.us-west-000.backblazeb2.com/proxycurl/person/ericnessdata/profile?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=0004d7f56a0400b0000000001%2F20230528%2Fus-west-000%2Fs3%2Faws4_request&X-Amz-Date=20230528T225639Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=fbeb1506bcd70a2ad22de7953eb24793afe65c5f6618ad47e0e15c293a28be75", | |
"background_cover_image_url": "https://s3.us-west-000.backblazeb2.com/proxycurl/person/ericnessdata/cover?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=0004d7f56a0400b0000000001%2F20230528%2Fus-west-000%2Fs3%2Faws4_request&X-Amz-Date=20230528T225639Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=20ed017262c2885e72c7539aefa906971fd3d529dad43dbc9a48581ed8ab437e", | |
"first_name": "Eric", | |
"last_name": "Ness", | |
"full_name": "Eric Ness", | |
"follower_count": 1554, | |
"occupation": "Principal Machine Learning Engineer at C.H. Robinson", | |
"headline": "Principal Machine |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def countSubstrings(self, s: str) -> int: | |
"""Find number of palindromic strings in s | |
Args: | |
s (str): String to analyze | |
Returns: | |
int: Count of palindromes | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def countSubstrings(self, s: str) -> int: | |
"""Find number of palindromic strings in s | |
Args: | |
s (str): String to analyze | |
Returns: | |
int: Count of palindromes | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Optional | |
class ListNode: | |
def __init__(self, val=0, next=None): | |
self.val = val | |
self.next = next | |
class Solution: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Optional | |
class ListNode: | |
def __init__(self, val=0, next=None): | |
self.val = val | |
self.next = next | |
class Solution: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if current == head and node_to_remove == 0: | |
head = current.next | |
elif current.next: | |
current.next = current.next.next | |
else: | |
current.next = None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Optional | |
class ListNode: | |
def __init__(self, val=0, next=None): | |
self.val = val | |
self.next = next | |
class Solution: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import collections | |
from enum import Enum | |
from typing import List, Set, Tuple | |
Node = collections.namedtuple("Node", "row col") | |
Direction = collections.namedtuple("Direction", "rows_down cols_right") | |
DIRECTIONS = [ | |
Direction(-1, 0), | |
Direction(1, 0), |
NewerOlder