Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/gradle/kotlin-1.9.20
Browse files Browse the repository at this point in the history
  • Loading branch information
tomascayuelas authored Nov 15, 2023
2 parents 461cd1f + d1eafd9 commit afd9a95
Show file tree
Hide file tree
Showing 374 changed files with 11,680 additions and 3,884 deletions.
150 changes: 150 additions & 0 deletions .github/workflows/openai-api-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
name: Check OpenAI API

on:
workflow_dispatch:

jobs:
checkAPIVersion:
runs-on: ubuntu-latest
steps:
- name: Install Octokit Action
run: npm install @octokit/action
- name: Get latest API commit
id: get-latest-commit
uses: actions/github-script@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
result-encoding: string
script: '
const { Octokit } = require("@octokit/action");
const octokit = new Octokit();
const owner = ''openai'';
const repo = ''openai-openapi'';
const filePath = ''openapi.yaml'';
const branch = ''master'';
const commits = await octokit.repos.listCommits({
owner,
repo,
path: filePath,
ref: branch
});
return commits.data[0].sha.trim();
'
- name: Get result latest API commit
run: |
LATEST_API_COMMIT="${{steps.get-latest-commit.outputs.result}}"
echo "LATEST_API_COMMIT=$LATEST_API_COMMIT" >> $GITHUB_ENV
- name: Get current API commit
id: get-current-commit
uses: actions/github-script@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
result-encoding: string
script: '
const { Octokit } = require("@octokit/action");
const octokit = new Octokit();
const owner = ''xebia-functional'';
const repo = ''xef'';
const filePath = ''openai-client/generator/config/openai-api-commit'';
const branch = ''main'';
const response = await octokit.repos.getContent({
owner,
repo,
path: filePath,
ref: branch,
});
const content = Buffer.from(response.data.content, ''base64'').toString(''utf-8'');
return content.trim();
'
- name: Get result current API commit
run: |
CURRENT_API_COMMIT="${{steps.get-current-commit.outputs.result}}"
echo "CURRENT_API_COMMIT=$CURRENT_API_COMMIT" >> $GITHUB_ENV
- name: Check existing PR
if: env.CURRENT_API_COMMIT != env.LATEST_API_COMMIT
id: get-pr-commit
uses: actions/github-script@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
result-encoding: string
script: '
const { Octokit } = require("@octokit/action");
const octokit = new Octokit();
const owner = ''xebia-functional'';
const repo = ''xef'';
const filePath = ''openai-client/generator/config/openai-api-commit'';
const existing = await octokit.pulls.list({
owner,
repo,
head: ''xebia-functional:update/openai-client''
});
if (existing.data.length > 0) {
const prCommit = existing.data[0].head.sha;
const response = await octokit.repos.getContent({
owner,
repo,
path: filePath,
ref: prCommit
});
const prApiCommit = Buffer.from(response.data.content, ''base64'').toString(''utf-8'').trim();
if (prApiCommit === ''${{ env.LATEST_API_COMMIT }}'') {
return prApiCommit;
} else {
return '''';
}
} else {
return '''';
}
'
- name: Update current commit with PR
if: env.CURRENT_API_COMMIT != env.LATEST_API_COMMIT
run: |
PR_API_COMMIT="${{steps.get-pr-commit.outputs.result}}"
if [[ ! -z "$PR_API_COMMIT" ]]
then
echo "CURRENT_API_COMMIT=$PR_API_COMMIT" >> $GITHUB_ENV
else
echo "Previous PR outdated or nonexistent"
fi
- name: Checkout
if: env.CURRENT_API_COMMIT != env.LATEST_API_COMMIT
uses: actions/checkout@v4
- name: Update commit
if: env.CURRENT_API_COMMIT != env.LATEST_API_COMMIT
run: |
echo $LATEST_API_COMMIT > $GITHUB_WORKSPACE/openai-client/generator/config/openai-api-commit
- name: Set up Java
if: env.CURRENT_API_COMMIT != env.LATEST_API_COMMIT
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 20
- name: Download new API spec
if: env.CURRENT_API_COMMIT != env.LATEST_API_COMMIT
uses: gradle/gradle-build-action@v2
with:
arguments: downloadOpenAIAPI
- name: Generate new OpenAI client
if: env.CURRENT_API_COMMIT != env.LATEST_API_COMMIT
uses: gradle/gradle-build-action@v2
with:
arguments: openaiClientGenerate
- name: Spotless Apply
if: env.CURRENT_API_COMMIT != env.LATEST_API_COMMIT
uses: gradle/gradle-build-action@v2
with:
arguments: spotlessApply
- name: Create PR
if: env.CURRENT_API_COMMIT != env.LATEST_API_COMMIT
uses: peter-evans/create-pull-request@v5
with:
commit-message: 'Update OpenAI Client'
branch: update/openai-client
title: 'Update OpenAI client'
body: 'Updates the OpenAI client based on the latest changes.'
36 changes: 2 additions & 34 deletions .github/workflows/publish-development-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Assemble
uses: gradle/gradle-build-action@v2
with:
arguments: assemble -x:xef-java-examples:assemble -x:xef-scala:assemble -x:xef-scala-examples:assemble
arguments: assemble

- name: Upload reports
if: failure()
Expand All @@ -46,36 +46,4 @@ jobs:
- name: Publish development version
uses: gradle/gradle-build-action@v2
with:
arguments: publishToSonatype -x:xef-scala:publishToSonatype closeAndReleaseSonatypeStagingRepository

publish-modules-with-loom:
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref_name }}

- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 20

- name: assemble
uses: gradle/gradle-build-action@v2
with:
arguments: :xef-scala:assemble :xef-java-examples:assemble

- name: Upload reports
if: failure()
uses: actions/upload-artifact@v3
with:
name: 'reports-${{ matrix.os }}'
path: '**/build/reports/**'

- name: Publish development version
uses: gradle/gradle-build-action@v2
with:
arguments: :xef-scala:publishToSonatype closeAndReleaseSonatypeStagingRepository
arguments: publishToSonatype closeAndReleaseSonatypeStagingRepository
36 changes: 2 additions & 34 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Assemble
uses: gradle/gradle-build-action@v2
with:
arguments: assemble -x:xef-java-examples:assemble -x:xef-scala:assemble -x:xef-scala-examples:assemble
arguments: assemble

- name: Upload reports
if: failure()
Expand All @@ -44,36 +44,4 @@ jobs:
- name: Publish final version
uses: gradle/gradle-build-action@v2
with:
arguments: publishToSonatype -x:xef-scala:publishToSonatype closeSonatypeStagingRepository

publish-modules-with-loom:
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref_name }}

- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 20

- name: assemble
uses: gradle/gradle-build-action@v2
with:
arguments: :xef-scala:assemble :xef-java-examples:assemble

- name: Upload reports
if: failure()
uses: actions/upload-artifact@v3
with:
name: 'reports-${{ matrix.os }}'
path: '**/build/reports/**'

- name: Publish final version
uses: gradle/gradle-build-action@v2
with:
arguments: :xef-scala:publishToSonatype closeSonatypeStagingRepository
arguments: publishToSonatype closeSonatypeStagingRepository
63 changes: 10 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Our goal is to make the move to this new world as simple as possible for the dev
xef.ai is packaged in two layers:
1. Core libraries bringing integration with the basic services in an AI application.
These libraries expose an _idiomatic_ interface, so there's one per programming language.
At this moment we support Kotlin and Scala.
At this moment we support Kotlin.
2. Integrations with other libraries which complement the core mission of xef.ai.

xef.ai draws inspiration from libraries like [LangChain](https://docs.langchain.com/docs/)
Expand Down Expand Up @@ -47,77 +47,34 @@ strategies.

Libraries are published in Maven Central, under the `com.xebia` group.

1. `xef-kotlin` for Kotlin support, `xef-scala` for Scala, `xef-java` for Java.
2. The name of a library we provide integration for, like `xef-lucene`.
1. `xef-core` is the core library.
2. `xef-openai` is the integration with OpenAI's API.
3. The name of a library we provide integration for, like `xef-lucene`.

<details>
<summary><img src="https://upload.wikimedia.org/wikipedia/commons/3/37/Kotlin_Icon_2021.svg" height="15px" alt="Kotlin logo"> Gradle (Kotlin DSL)</summary>

Libraries are published in Maven Central. You may need to add that repository explicitly
in your build, if you haven't done it before.
You may need to add that repository explicitly in your build, if you haven't done it before.

```groovy
repositories { mavenCentral() }
```

Then add the library in the usual way.
Then add the libraries in the usual way.

```groovy
// In Gradle Kotlin
dependencies {
implementation("com.xebia:xef-kotlin:<version>")
implementation("com.xebia:xef-core:<version>")
implementation("com.xebia:xef-openai:<version>")
}
```

We publish all libraries at once under the same version, so
[version catalogs](https://docs.gradle.org/current/userguide/platforms.html#sec:sharing-catalogs)
could be useful.

</details>

<details>
<summary><img src="https://www.scala-lang.org/resources/img/frontpage/scala-spiral.png" height="15px" alt="Scala logo"> SBT</summary>

```sbt
libraryDependencies += "com.xebia" %% "xef-scala" % "<version>"
```

> **Warning**
> `xef-scala` is currently only available for Scala 3, and depends on project [Loom](https://openjdk.org/projects/loom/),
> so you will need at least Java 20 to use the library.
</details>

<details>
<summary><img src="https://upload.wikimedia.org/wikipedia/commons/5/52/Apache_Maven_logo.svg" height="15px" alt="Maven logo"> Maven</summary>

Libraries are published in Maven Central. You may need to add that repository explicitly
in your build, if you haven't done it before.

```xml
<dependency>
<groupId>com.xebia</groupId>
<artifactId>xef-java</artifactId>
<version>x.x.x</version>
<type>pom</type>
<scope>runtime</scope>
</dependency>
```

</details>

## 📖 Quick Introduction

In this small introduction we look at the main features of xef, including the `conversation` function.

- [<img src="https://upload.wikimedia.org/wikipedia/commons/3/37/Kotlin_Icon_2021.svg" height="15px" alt="Kotlin logo"> Kotlin version](https://github.com/xebia-functional/xef/blob/main/docs/intro/kotlin.md)
- [<img src="https://www.scala-lang.org/resources/img/frontpage/scala-spiral.png" height="15px" alt="Scala logo"> Scala version](https://github.com/xebia-functional/xef/blob/main/docs/intro/scala.md)
- [<img src="https://upload.wikimedia.org/wikipedia/en/thumb/3/30/Java_programming_language_logo.svg/234px-Java_programming_language_logo.svg.png" height="15px" alt="Java logo"> Java version](https://github.com/xebia-functional/xef/blob/main/docs/intro/java.md)
In [this](https://github.com/xebia-functional/xef/blob/main/docs/intro.md) small introduction we look at the main features of xef, including the `conversation` function.

## 🚀 Examples

You can also have a look at the examples to have a feeling of how using the library looks like.

- [<img src="https://upload.wikimedia.org/wikipedia/commons/3/37/Kotlin_Icon_2021.svg" height="15px" alt="Kotlin logo"> Examples in Kotlin](https://github.com/xebia-functional/xef/tree/main/examples/kotlin/src/main/kotlin/com/xebia/functional/xef/conversation)
- [<img src="https://www.scala-lang.org/resources/img/frontpage/scala-spiral.png" height="15px" alt="Scala logo"> Examples in Scala](https://github.com/xebia-functional/xef/tree/main/examples/scala/src/main/scala/com/xebia/functional/xef/examples/scala)
- [<img src="https://upload.wikimedia.org/wikipedia/en/thumb/3/30/Java_programming_language_logo.svg/234px-Java_programming_language_logo.svg.png" height="15px" alt="Java logo"> Examples in Java](https://github.com/xebia-functional/xef/tree/main/examples/java/src/main/java/com/xebia/functional/xef/java/auto)
You can also have a look at the [examples](https://github.com/xebia-functional/xef/tree/main/examples/src/main/kotlin/com/xebia/functional/xef/conversation) to have a feeling of how using the library looks like.
Loading

0 comments on commit afd9a95

Please sign in to comment.