Created
November 23, 2023 12:47
-
-
Save ashpreetbedi/9043d0ec27f279085eac15aeab6ab9ea to your computer and use it in GitHub Desktop.
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 json | |
| import requests | |
| from phi.conversation import Conversation | |
| def get_top_hackernews_stories() -> str: | |
| """Use this function to get top stories from Hacker News.""" | |
| response = requests.get('https://hacker-news.firebaseio.com/v0/topstories.json') | |
| story_ids = response.json() | |
| stories = [] | |
| for story_id in story_ids[:30]: | |
| story_response = requests.get(f'https://hacker-news.firebaseio.com/v0/item/{story_id}.json') | |
| story = story_response.json() | |
| if "text" in story: | |
| story.pop("text", None) | |
| stories.append(story) | |
| return json.dumps(stories) | |
| conversation = Conversation(tools=[get_top_hackernews_stories], show_function_calls=True) | |
| conversation.print_response("What's trending about LLMs, AI or OpenAI.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment