Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit 24c3824

Browse files
author
Ja Young Lee
committed
Merge branch 'develop' of github.com:IBM/ibm-generative-ai into 24-doc-restructure
2 parents 45d96a7 + 75dacd8 commit 24c3824

File tree

13 files changed

+322
-42
lines changed

13 files changed

+322
-42
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: 📘 Update documentation
3+
about: Update the repo's documentation
4+
title: DOCS
5+
labels: documentation, good first issue, help wanted
6+
assignees: ''
7+
8+
---
9+
**What type of documentation needs to be updated?**
10+
[ ] [API documentation](https://ibm.github.io/ibm-generative-ai/)
11+
[ ] [Code of Conduct (CoC)](/CODE_OF_CONDUCT.md)
12+
[ ] [Contribution Guide](/DEVELOPMENT.md)
13+
[ ] [README file](/README.md)
14+
[ ] [Project Team](/ACTIVE_PROJECT_TEAM.md)
15+
16+
**Is your documentation update related to a problem/software issue? Please describe.**
17+
A clear and concise description of what the problem is. Ex. The API documentation must be updated [...] , The project team changed, we need to update the project team markdown file [...], etc.
18+
19+
**Additional context**
20+
Add any other context or screenshots about how documentation must be updated.

.github/workflows/integration-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
run: |
2929
python -m pip install --upgrade pip
3030
python -m pip install -e ".[dev]"
31+
python -m pip install -e ".[all]"
3132
- name: Run integration tests
3233
env:
3334
GENAI_API: ${{ vars.GENAI_API }}

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
push:
88
branches: [ "main", "develop" ]
99
pull_request:
10-
branches: [ "main", "develop" ]
10+
branches: [ "main", "develop" ]
1111

1212
jobs:
1313
build:

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ repos:
99
- id: check-case-conflict
1010
- id: check-added-large-files
1111
- repo: https://github.com/psf/black
12-
rev: 23.1.0
12+
rev: 23.3.0
1313
hooks:
1414
- id: black
1515
args:

ACTIVE_PROJECT_TEAM.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# IBM Generative AI Active Maintainers
2+
[Onkar Bhardwaj](https://github.com/onkarbhardwaj)
3+
[Veronique Demers](https://github.com/vedem1192)
4+
[James Sutton](https://github.com/jpwsutton)
5+
[Ja Young Lee](https://github.com/jayolee)
6+
[Mírian Silva](https://github.com/mirianfsilva)
7+
[Mairead O'Neill](https://github.com/moneill0)
8+
9+
# Open-source contributions advocate
10+
[Adriana Meza](https://github.com/ameza13)

CODE_OF_CONDUCT.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Community Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
- Using welcoming and inclusive language
18+
- Being respectful of differing viewpoints and experiences
19+
- Gracefully accepting constructive criticism
20+
- Focusing on what is best for the community
21+
- Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
- The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
- Trolling, insulting/derogatory comments, and personal or political attacks
28+
- Public or private harassment
29+
- Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
- Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the [project team](./ACTIVE_PROJECT_TEAM.md). All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq

DEVELOPMENT.md

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22
# IBM Generative AI Development Guide
33

44
<!-- vscode-markdown-toc -->
5-
* [Setup the Development Environment](#SetuptheDevelopmentEnvironment)
6-
* [Pre-requisites](#Pre-requisites)
7-
* [Using Venv](#UsingVenv)
8-
* [Clone repo and checkout dev branch](#Clonerepoandcheckoutdevbranch)
9-
* [Install requirements](#Installrequirements)
10-
* [Setup your IBM Gen AI token](#SetupyourGenAItoken)
11-
* [Make Changes](#MakeChanges)
12-
* [Commit Changes and Make a Pull Request](#CommitChangesandMakeaPullRequest)
13-
* [Logging](#Logging)
14-
* [Enabling Logs](#EnablingLogs)
15-
* [Deployment Process](#DeploymentProcess)
5+
* [Setup the Development Environment](#setup-the-development-environment)
6+
* [Pre-requisites](#pre-requisites)
7+
* [Using Venv](#using-venv)
8+
* [Fork the official repo](#fork-the-official-repo)
9+
* [Clone the forked repo and checkout develop branch](#clone-repo-and-checkout-develop-branch)
10+
* [Install requirements](#install-requirements)
11+
* [Setup your IBM Gen AI token](#setup-your-ibm-generative-ai-token)
12+
* [Make Changes](#make-changes)
13+
* [Commit Changes and Make a Pull Request](#commit-changes-and-make-a-pull-request)
14+
* [Logging](#logging)
15+
* [Enabling Logs](#logging)
16+
<!-- * [Deployment Process](#DeploymentProcess)
1617
* [Automated Release Process](#AutomatedReleaseProcess)
17-
* [Manual Release Process](#ManualProcess)
18+
* [Manual Release Process](#ManualProcess) -->
1819

1920

2021
<!-- vscode-markdown-toc-config
@@ -23,15 +24,15 @@
2324
/vscode-markdown-toc-config -->
2425
<!-- /vscode-markdown-toc -->
2526

26-
## <a name='SetuptheDevelopmentEnvironment'></a>Setup the Development Environment
27+
## Setup the Development Environment
2728

28-
### <a name='Pre-requisites'></a>Pre-requisites
29+
### Pre-requisites
2930

3031
- Python version >= 3.9.
3132
- Setup a virtual environment (using [venv](https://docs.python.org/3/library/venv.html) or [conda](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html)) and activate it.
3233
- You need to **activate this environment every time** before you want to make changes to this repository.
3334

34-
#### <a name='UsingVenv'></a>Using Venv
35+
#### Using Venv
3536
```bash
3637
python -m venv .venv # Create your Virtual environment
3738
source .venv/bin/activate # Activate and use your virtual environment
@@ -40,16 +41,23 @@ source .venv/bin/activate # Activate and use your virtual environment
4041
# And once you're all done..
4142
deactivate
4243
```
44+
### Fork the official repo
4345

46+
1. Navigate to https://github.com/IBM/ibm-generative-ai repository.
47+
2. In the top-right corner of the page, click **Fork**.
48+
*Important: **DO NOT** select 'Copy the DEFAULT branch only' option.*
49+
3. Click **Create fork** .
4450

45-
### <a name='Clonerepoandcheckoutdevbranch'></a>Clone repo and checkout dev branch
51+
Further information on how to fork a GitHub repository is avaiable [here](https://docs.github.com/en/get-started/quickstart/fork-a-repo).
52+
53+
### Clone repo and checkout develop branch
4654

4755
```bash
48-
git clone <repository-link>
49-
git checkout dev
56+
git clone <forked-repository-link>
57+
git checkout develop
5058
```
5159

52-
### <a name='Installrequirements'></a>Install requirements
60+
### Install requirements
5361

5462
Minimal pip version is 22.0.1. Check your pip version with `pip --version` and if needed run the following command to upgrade pip.
5563
```bash
@@ -64,7 +72,7 @@ Install pre-commit setup
6472
pre-commit install
6573
```
6674

67-
### <a name='SetupyourIBMGenAItoken'></a>Setup your IBM Generative AI token
75+
### Setup your IBM Generative AI token
6876
Login to [workbench.res.ibm.com/](https://workbench.res.ibm.com/) and get your IBM Generative AI API key. Then, create a `genai/.env` and assign the `GENAI_KEY` value as:
6977
```
7078
GENAI_KEY=<your key here>
@@ -73,17 +81,20 @@ GENAI_KEY=<your key here>
7381
Once done, you and genai can use your key using `os.getenv("GENAI_KEY")` and you will not
7482
have to worry about committing it to GitHub.
7583

76-
## <a name='MakeChanges'></a>Make Changes
84+
## Make Changes
7785
Create a branch for making changes
86+
7887
```bash
79-
git checkout -b <my_awesome_branch>
88+
git checkout -b <my_awesome_branch> develop
8089
```
90+
*Important: Note we branched off 'develop' not 'main'*
91+
8192
Make your changes and add any unit tests. Run tests as
8293
```bash
8394
python -m pytest
8495
```
8596

86-
## <a name='CommitChangesandMakeaPullRequest'></a>Commit Changes and Make a Pull Request
97+
## Commit Changes and Make a Pull Request
8798
Once you are done making changes, run `flake8` for linting and try fixing for as many messages as possible.
8899
```bash
89100
flake8 .
@@ -100,12 +111,15 @@ Push your changes
100111
```bash
101112
git push origin HEAD
102113
```
103-
Raise a pull request from your `<my_awesome_branch>` containing changes to `dev` branch by going to github page of the repo.
114+
Raise a pull request from your `<my_awesome_branch>` in the `head repository` to the `develop` branch in the `base repository`. To do so go to the github page of the repo. The image below shows an example:
115+
116+
![image](/documentation/assets/pull_request_from_fork_to_base.png)
117+
104118
- Add a description for your PR.
105119
- Link any issues.
106120
- Wait for tests to pass. If they fail then try to fix issues. Get in touch with the core team if needed. They will get back to you for anything that needs to be addressed.
107121

108-
## <a name='Logging'></a>Logging
122+
## Logging
109123

110124
GenAI uses the standard python logging module for logging debug messages within the module. Unless the consuming application explicitly enables logging, no logging messags from GenAI should appear in stdout or stderr e.g. no `print` statements, we should also always log to the `genai` namespace so that logs are easily identifiable.
111125

EXTENSIONS.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# IBM Generative AI Extensions Guide
2+
Open-source contributors are welcome to extend IBM Gen AI functionality via extensions that must keep the IBM Gen AI package as a dependency. This document explains what extensions are, the types of extensions that exist, and how to create them.
3+
4+
# Table of Contents
5+
- [About the core package](#ibm-generative-ai-core-package)
6+
- [What is an extension?](#what-is-an-ibm-generative-ai-extension)
7+
- [Types of extensions](#ibm-generative-ai-extension-types)
8+
- [Extensions migration](#extensions-migration)
9+
- [Design considerations](#design-considerations-to-build-extensions)
10+
11+
# IBM Generative AI Core Package
12+
[IBM Generative AI open-source repository](https://github.com/IBM/ibm-generative-ai) lives under [IBM Github organization](https://github.com/IBM/). This repository is the official and unique location of IBM Gen AI core package source code.
13+
14+
# What is an IBM Generative AI Extension?
15+
An extension is a software add-on that is installed on a program to enhance its capabilities. Gen AI extensions are meant to expand the capabilities of the Gen AI core package. For instance, imagine that you want to build a prompt pattern with data from a pandas dataframe. You could write your own code to achive such functionaliy, or you could instead use the Gen AI Pandas extension. Using the extension will allow you to save development time and deliver an elegant solution that re-uses code when it is possible.
16+
17+
# IBM Generative AI Extension types
18+
IBM Generative AI extensions can be either of the following :
19+
- official open-source extensions (supported by the project team)
20+
- third-party open-source extensions
21+
22+
## Open-source "Gen AI official" extensions
23+
Extensions that are meant for public use from the get-go should instead be developed as official open-source extensions. Examples of official extensions that have already been released are LangChain, Pandas, and Hugging Face extensions.
24+
25+
### Ownership and location
26+
Open-source extensions should be submitted directly to the [IBM Generative AI open-source repository](https://github.com/IBM/ibm-generative-ai) and should be developed following the [open-source Gen AI contribution guide](https://github.com/IBM/ibm-generative-ai/blob/main/DEVELOPMENT.md). Open-source official extensions are typically developed by the Gen AI team, or in collaboration with them. Providing maintenance to open-source official extensions is responsability of the Gen AI team.
27+
28+
## Open-source "third-party" extensions
29+
All other extensions neither implemented nor officially maintained by the Gen AI team are referred to as open-source third-party extensions.
30+
31+
### Ownership and location
32+
Open-source third-party extensions can live anywhere, inside [IBM organization](https://github.com/IBM/), the wider Github universe, or other contributors' own Github spaces (e.g., other IBM teams, clients, partners). Maintaining these extensions would be the responsibility of their owners.
33+
34+
# Extensions migration
35+
Extensions might be migrated from one type to another upon evaluation and approval of the Gen AI maintenance team. Below, we describe two common migration scenarios:
36+
37+
## Open-source "third-party" to open-source "Gen AI official"
38+
If open-source third-party contributors have an interest in their extensions becoming official, they must contact the IBM Gen AI team. The Gen AI team will evaluate the request considering novelty and implementation quality (meaning it was developed following the Gen AI official guide and meets Gen AI extensions' design considerations). If the request is approved, the Gen AI team will assist the extension owners in migrating the extension.
39+
40+
## Open-source "Gen AI official" to Gen AI's core
41+
Upon evaluation of the Gen AI maintenance team, open-source extensions could be merged with Gen AI core code and become deprecated as extensions. Deprecation announcements will be shared as part of the release notes of every new version of the IBM Gen AI package.
42+
43+
# Design considerations to build extensions
44+
Among other patterns, a developer should consider a mix-and-match of the two following important development experience patterns to design an extension for IBM Gen AI SDK:
45+
46+
## Extensions that simulate being part of a core class
47+
48+
In spite of the extension's code living in a separate location, **try to give the impression that extended functionality is part of an IBM Gen AI core class**.
49+
50+
The code snippet below shows an example of this pattern. While `from_template` method is part of an extension class (`PromptExtension`) and not a core class (`PromptPattern`), the way it is being called gives end-users the impression that the method is part of the `PromptPattern` core class. The magic that enables providing this development experience is the use of decorators at import time. This pattern enables extending user-facing classes in a user-friendly way.
51+
52+
```python
53+
genai_prompt_pattern = PromptPattern.langchain.from_template(langchain_prompt_template)
54+
# notice langchain hook in the function call.
55+
```
56+
57+
## Extensions that wrap core class functionality
58+
59+
Designing extensions that do not integrate, but **wrap functionality in Gen AI's core** for common use cases. These classes are meant to be used as entities on their own.
60+
61+
The `LangChainInterface` class (see below) is an example of this pattern. `LangChainInterface` is a subclass of langchain's `LLM` class that wraps `generate` functionality of Gen AI's Model.
62+
63+
```python
64+
...
65+
66+
try:
67+
from langchain.llms.base import LLM
68+
from langchain.llms.utils import enforce_stop_tokens
69+
except ImportError:
70+
raise ImportError("Could not import langchain: Please install ibm-generative-ai[langchain] extension.")
71+
72+
...
73+
74+
class LangChainInterface(LLM, BaseModel):
75+
```
76+
77+
Click [here](https://github.com/IBM/ibm-generative-ai/blob/main/src/genai/extensions/langchain/llm.py)" to check the full definition of this class.

README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ This is the Python SDK for IBM Foundation Models Studio to bring IBM Generative
3333
* [LangChain Extension](#langchain-extension)
3434
* [Support](#support)
3535
* [API Documentation](#APIDocumentation)
36-
* [Contribution Guide](#contribution-guide)
36+
* [Important Information for Contributors](#important-information-for-contributors)
3737
* [Authors](#authors)
3838

3939
<!-- vscode-markdown-toc-config
@@ -51,6 +51,17 @@ pip install ibm-generative-ai
5151
#### <a name='KnownIssueFixes:'></a>Known Issue Fixes:
5252
- **[SSL Issue]** If you run into "SSL_CERTIFICATE_VERIFY_FAILED" please run the following code snippet here: [support](SUPPORT.md).
5353

54+
### <a name='Prerequisites'></a>Prerequisites
55+
Python version >= 3.9
56+
57+
Pip version >= 22.0.1
58+
59+
Check your pip version with `pip --version` and if needed run the following command to upgrade pip.
60+
61+
```bash
62+
pip install --upgrade "pip>=22.0.1"
63+
```
64+
5465

5566
## <a name='GenAIEndpoint'></a>Gen AI Endpoint
5667

@@ -315,9 +326,9 @@ Need help? Check out how to get [support](SUPPORT.md)
315326

316327
Read our Python API documentation [here](https://ibm.github.io/ibm-generative-ai/).
317328

318-
## <a name='ContributionGuide'></a>Contribution Guide
329+
## <a name='ContributionInfo'></a>Important Information for Contributors
319330

320-
Please read our [contributing guide](DEVELOPMENT.md) for details on our code of conduct and details on submitting pull requests.
331+
IBM Generative AI is an open-source project that welcomes the community to contribute with documentation, tests, bug corrections, and new fuctionality in the form of [extensions](/EXTENSIONS.md). Please read our [code of counduct](/CODE_OF_CONDUCT.md) to learn the expected behavior from participants that contribute to the project, and our [contribution guide](DEVELOPMENT.md) to learn the gitflow and steps to submit pull requests.
321332

322333
## <a name='Authors'></a>Authors
323334
- Onkar Bhardwaj, onkarbhardwaj@ibm.com
38.3 KB
Loading

0 commit comments

Comments
 (0)