Skip to content

Commit

Permalink
Fix missing new templates (#12)
Browse files Browse the repository at this point in the history
* Bump version.

* Include cohere and google files to the dist.

* Change log.
  • Loading branch information
olpa authored Oct 17, 2024
1 parent cb0593a commit d45bc60
Show file tree
Hide file tree
Showing 16 changed files with 195 additions and 6 deletions.
11 changes: 8 additions & 3 deletions apis/Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
LIB_FILES :=$(wildcard lib/*.jsonnet)

SCHEMA_FILES := $(wildcard schemas/*.json)

OPENAI_FILES := $(wildcard openai/lib/*.jsonnet) \
$(wildcard openai/fixture/*.json)

SCHEMA_FILES := $(wildcard schemas/*.json)

ANTHROPIC_FILES := $(wildcard anthropic/lib/*.jsonnet) \
$(wildcard anthropic/fixture/*.json)

COHERE_FILES := $(wildcard cohere/lib/*.jsonnet) \
$(wildcard cohere/fixture/*.json)

GOOGLE_FILES := $(wildcard google/lib/*.jsonnet) \
$(wildcard google/fixture/*.json)

DOC_FILES := README.md changelog.md

ALL_FILES := $(DOC_FILES) $(SCHEMA_FILES) $(LIB_FILES) $(OPENAI_FILES) $(ANTHROPIC_FILES)
ALL_FILES := $(DOC_FILES) $(SCHEMA_FILES) $(LIB_FILES) $(OPENAI_FILES) $(ANTHROPIC_FILES) $(COHERE_FILES) $(GOOGLE_FILES)
ALL_DIST_FILES := $(addprefix dist/, $(ALL_FILES))

dist: $(ALL_DIST_FILES)
Expand Down
2 changes: 1 addition & 1 deletion apis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,5 @@ The document structure will be more rich in the future. It will be based on the
# Using in NPM

```
npm install https://github.com/olpa/templating-for-api/releases/download/apis-v1.1.4/apis-v1.1.4.tar.gz
npm install https://github.com/olpa/templating-for-api/releases/download/apis-v1.1.5/apis-v1.1.5.tar.gz
```
5 changes: 5 additions & 0 deletions apis/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [2024-10-17] - v1.1.5

- Add Cohere and Google to the distro package


## [2024-10-16] - v1.1.4

- Add Cohere CommandR
Expand Down
2 changes: 1 addition & 1 deletion apis/dist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,5 @@ The document structure will be more rich in the future. It will be based on the
# Using in NPM

```
npm install https://github.com/olpa/templating-for-api/releases/download/apis-v1.1.4/apis-v1.1.4.tar.gz
npm install https://github.com/olpa/templating-for-api/releases/download/apis-v1.1.5/apis-v1.1.5.tar.gz
```
5 changes: 5 additions & 0 deletions apis/dist/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [2024-10-17] - v1.1.5

- Add Cohere and Google to the distro package


## [2024-10-16] - v1.1.4

- Add Cohere CommandR
Expand Down
13 changes: 13 additions & 0 deletions apis/dist/cohere/fixture/document.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"doc": [
{
"type": "markdown",
"content": [
{
"type": "text",
"text": "Hi! Hello to you too! How's it going?"
}
]
}
]
}
9 changes: 9 additions & 0 deletions apis/dist/cohere/fixture/request.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"model": "command-r",
"messages": [
{
"role": "user",
"content": "hello"
}
]
}
23 changes: 23 additions & 0 deletions apis/dist/cohere/fixture/response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"id": "1b8fc799-4e6d-444b-9374-80f3f9e53788",
"message": {
"role": "assistant",
"content": [
{
"type": "text",
"text": "Hi! Hello to you too! How's it going?"
}
]
},
"finish_reason": "COMPLETE",
"usage": {
"billed_units": {
"input_tokens": 1,
"output_tokens": 12
},
"tokens": {
"input_tokens": 67,
"output_tokens": 12
}
}
}
16 changes: 16 additions & 0 deletions apis/dist/cohere/lib/document-tpl.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
local response = std.parseJson(std.extVar("response"));

{
doc: [
{
type: 'markdown',
content: [
{
type: 'text',
text: item.text
}
]
}
for item in response.message.content
]
}
7 changes: 7 additions & 0 deletions apis/dist/cohere/lib/request-tpl.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
local openai = import "openai-request-tpl.jsonnet";

openai.run("https://api.cohere.com/v2/chat", "bearer") + {
body+: {
model: "command-r",
},
}
13 changes: 13 additions & 0 deletions apis/dist/google/fixture/document.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"doc": [
{
"type": "markdown",
"content": [
{
"type": "text",
"text": "Hello! How can I help you today? \n"
}
]
}
]
}
18 changes: 18 additions & 0 deletions apis/dist/google/fixture/request.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"body": {
"contents": [
{
"parts": [
{
"text": "hello"
}
]
}
]
},
"headers": {
"Content-type": "application/json"
},
"url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-pro:generateContent?key=LLM_KEY",
"method": "POST"
}
40 changes: 40 additions & 0 deletions apis/dist/google/fixture/response.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

{
"candidates": [
{
"content": {
"parts": [
{
"text": "Hello! How can I help you today? \n"
}
],
"role": "model"
},
"finishReason": "STOP",
"index": 0,
"safetyRatings": [
{
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HATE_SPEECH",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_HARASSMENT",
"probability": "NEGLIGIBLE"
},
{
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"probability": "NEGLIGIBLE"
}
]
}
],
"usageMetadata": {
"promptTokenCount": 1,
"candidatesTokenCount": 10,
"totalTokenCount": 11
}
}
17 changes: 17 additions & 0 deletions apis/dist/google/lib/document-tpl.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
local response = std.parseJson(std.extVar("response"));

{
doc: std.flattenArrays([
[
{
type: "markdown",
content: [{
type: "text",
text: part.text,
}]
}
for part in candidate.content.parts
]
for candidate in response.candidates
])
}
18 changes: 18 additions & 0 deletions apis/dist/google/lib/request-tpl.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
local model = "gemini-1.5-pro";
local key = std.extVar("secret1");
local prompt = std.extVar("prompt");

{
url: "https://generativelanguage.googleapis.com/v1beta/models/%(model)s:generateContent?key=%(key)s" % {"model": model, "key": key},
method: "POST",
headers: {
"Content-type": "application/json",
},
body: {
contents: [{
parts: [{
text: prompt
}],
}],
},
}
2 changes: 1 addition & 1 deletion apis/dist/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tplfa-apis",
"version": "1.1.4",
"version": "1.1.5",
"description": "APIs for API templating",
"keywords": [],
"author": "Oleg Parashchenko",
Expand Down

0 comments on commit d45bc60

Please sign in to comment.