-
Notifications
You must be signed in to change notification settings - Fork 14.2k
docs: AI project, with framework #1505
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
This PR introduces an AI framework documentation project that demonstrates how to use LangChain with GitHub Models. The purpose is to provide educational content and code examples for building AI applications using frameworks rather than direct API calls.
Key changes include:
- Complete documentation explaining AI framework benefits and usage patterns
- Python code examples demonstrating basic prompting, chat conversations, and tool calling
- Practical implementations showing integration with external APIs
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 10 comments.
File | Description |
---|---|
10-ai-framework-project/README.md | Comprehensive documentation covering AI frameworks, LangChain usage, and detailed code examples |
10-ai-framework-project/code/python/app.py | Basic LangChain implementation for simple prompting |
10-ai-framework-project/code/python/app-chat.py | Chat conversation example with message history |
10-ai-framework-project/code/python/app-tools.py | Tool calling implementation with external API integration |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
@@ -0,0 +1,374 @@ | |||
# AI Framework | |||
|
|||
There are many AI frameworks out there that when used can severly quicken up the time it takes to build a project. In this project we will focus on understanding what problems these frameworks address and build such a project ourselves. |
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.
Corrected spelling of 'severly' to 'severely'.
There are many AI frameworks out there that when used can severly quicken up the time it takes to build a project. In this project we will focus on understanding what problems these frameworks address and build such a project ourselves. | |
There are many AI frameworks out there that when used can severely quicken up the time it takes to build a project. In this project we will focus on understanding what problems these frameworks address and build such a project ourselves. |
Copilot uses AI. Check for mistakes.
|
||
- **No SDK**, most AI models allows you to interact directly with the AI model via for example HTTP requests. That approach works and may sometimes be your only option if an SDK option is missing. | ||
- **SDK**. Using an SDK is usually the recommended approach as it allows you to type less code to interact with your model. It usually is limited to a specific model and if using different models, you might need to write new code to support those additional models. | ||
- **A framework**. A framework usually takes things to another level in the sense that if you need to use different models, there's one API for all of them, what differs is usually the initial set up. Additionally frameworks brings in useful abstractions like in the AI space, they can deal with tools, memory, workflows, agents and more while writing less code. Because frameworks are usually opinionated they can really be helpful if you buy into how they do things but may fall short if you try to do something bespoke that the framework isn't made for. Sometimes a framework can also simplify too much and you may therefore not learn an important topic that later may harm perfomance for example. |
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.
Corrected spelling of 'perfomance' to 'performance'.
- **A framework**. A framework usually takes things to another level in the sense that if you need to use different models, there's one API for all of them, what differs is usually the initial set up. Additionally frameworks brings in useful abstractions like in the AI space, they can deal with tools, memory, workflows, agents and more while writing less code. Because frameworks are usually opinionated they can really be helpful if you buy into how they do things but may fall short if you try to do something bespoke that the framework isn't made for. Sometimes a framework can also simplify too much and you may therefore not learn an important topic that later may harm perfomance for example. | |
- **A framework**. A framework usually takes things to another level in the sense that if you need to use different models, there's one API for all of them, what differs is usually the initial set up. Additionally frameworks brings in useful abstractions like in the AI space, they can deal with tools, memory, workflows, agents and more while writing less code. Because frameworks are usually opinionated they can really be helpful if you buy into how they do things but may fall short if you try to do something bespoke that the framework isn't made for. Sometimes a framework can also simplify too much and you may therefore not learn an important topic that later may harm performance for example. |
Copilot uses AI. Check for mistakes.
|
||
## Chat conversation | ||
|
||
In the preceeding section, you saw how we used what's normally known as zero shot prompting, a single prompt followed by a response. |
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.
Corrected spelling of 'preceeding' to 'preceding'.
In the preceeding section, you saw how we used what's normally known as zero shot prompting, a single prompt followed by a response. | |
In the preceding section, you saw how we used what's normally known as zero shot prompting, a single prompt followed by a response. |
Copilot uses AI. Check for mistakes.
|
||
In the preceeding section, you saw how we used what's normally known as zero shot prompting, a single prompt followed by a response. | ||
|
||
However, often you find yourselse in a situation where you need to maintain a conversation of several messages being exchanged between yourself and the AI assistant. |
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.
Corrected spelling of 'yourselse' to 'yourself'.
However, often you find yourselse in a situation where you need to maintain a conversation of several messages being exchanged between yourself and the AI assistant. | |
However, often you find yourself in a situation where you need to maintain a conversation of several messages being exchanged between yourself and the AI assistant. |
Copilot uses AI. Check for mistakes.
|
||
```python | ||
messages = [ | ||
SystemMessage(content="You are Captain Picard of the Startship Enterprise"), |
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.
Corrected spelling of 'Startship' to 'Starship'.
SystemMessage(content="You are Captain Picard of the Startship Enterprise"), | |
SystemMessage(content="You are Captain Picard of the Starship Enterprise"), |
Copilot uses AI. Check for mistakes.
) | ||
|
||
messages = [ | ||
SystemMessage(content="You are Captain Picard of the Startship Enterprise"), |
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.
Corrected spelling of 'Startship' to 'Starship'.
Copilot uses AI. Check for mistakes.
) | ||
|
||
messages = [ | ||
SystemMessage(content="You are Captain Picard of the Startship Enterprise"), |
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.
Corrected spelling of 'Startship' to 'Starship'.
SystemMessage(content="You are Captain Picard of the Startship Enterprise"), | |
SystemMessage(content="You are Captain Picard of the Starship Enterprise"), |
Copilot uses AI. Check for mistakes.
} | ||
``` | ||
|
||
What we're doing here is to create a description of a tool called `add`. By inheriting from `TypedDict` and adding members like `a` and `b` of type `Annotated` this can be converted to a schema that the LLM can understand. Ther creation of functions is a dictionary that ensures that we know what to do if a specific tool is identified. |
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.
Corrected spelling of 'Ther' to 'The'.
What we're doing here is to create a description of a tool called `add`. By inheriting from `TypedDict` and adding members like `a` and `b` of type `Annotated` this can be converted to a schema that the LLM can understand. Ther creation of functions is a dictionary that ensures that we know what to do if a specific tool is identified. | |
What we're doing here is to create a description of a tool called `add`. By inheriting from `TypedDict` and adding members like `a` and `b` of type `Annotated` this can be converted to a schema that the LLM can understand. The creation of functions is a dictionary that ensures that we know what to do if a specific tool is identified. |
Copilot uses AI. Check for mistakes.
print("CONTENT: ",res.content) | ||
``` | ||
|
||
Running this coode, you should see output similar to: |
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.
Corrected spelling of 'coode' to 'code'.
Running this coode, you should see output similar to: | |
Running this code, you should see output similar to: |
Copilot uses AI. Check for mistakes.
) | ||
|
||
messages = [ | ||
SystemMessage(content="You are Captain Picard of the Startship Enterprise"), |
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.
Corrected spelling of 'Startship' to 'Starship'.
SystemMessage(content="You are Captain Picard of the Startship Enterprise"), | |
SystemMessage(content="You are Captain Picard of the Starship Enterprise"), |
Copilot uses AI. Check for mistakes.
Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
Fixes # (issue)
Type of change