diff --git a/apis/Makefile b/apis/Makefile index 1f8f050..38fb616 100644 --- a/apis/Makefile +++ b/apis/Makefile @@ -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) diff --git a/apis/README.md b/apis/README.md index fab1cca..b464e82 100644 --- a/apis/README.md +++ b/apis/README.md @@ -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 ``` diff --git a/apis/changelog.md b/apis/changelog.md index fbab26a..0811036 100644 --- a/apis/changelog.md +++ b/apis/changelog.md @@ -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 diff --git a/apis/dist/README.md b/apis/dist/README.md index fab1cca..b464e82 100644 --- a/apis/dist/README.md +++ b/apis/dist/README.md @@ -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 ``` diff --git a/apis/dist/changelog.md b/apis/dist/changelog.md index fbab26a..0811036 100644 --- a/apis/dist/changelog.md +++ b/apis/dist/changelog.md @@ -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 diff --git a/apis/dist/cohere/fixture/document.json b/apis/dist/cohere/fixture/document.json new file mode 100644 index 0000000..fe64aed --- /dev/null +++ b/apis/dist/cohere/fixture/document.json @@ -0,0 +1,13 @@ +{ + "doc": [ + { + "type": "markdown", + "content": [ + { + "type": "text", + "text": "Hi! Hello to you too! How's it going?" + } + ] + } + ] +} diff --git a/apis/dist/cohere/fixture/request.json b/apis/dist/cohere/fixture/request.json new file mode 100644 index 0000000..7378d15 --- /dev/null +++ b/apis/dist/cohere/fixture/request.json @@ -0,0 +1,9 @@ +{ + "model": "command-r", + "messages": [ + { + "role": "user", + "content": "hello" + } + ] +} diff --git a/apis/dist/cohere/fixture/response.json b/apis/dist/cohere/fixture/response.json new file mode 100644 index 0000000..9b03f0d --- /dev/null +++ b/apis/dist/cohere/fixture/response.json @@ -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 + } + } +} diff --git a/apis/dist/cohere/lib/document-tpl.jsonnet b/apis/dist/cohere/lib/document-tpl.jsonnet new file mode 100644 index 0000000..7c1be24 --- /dev/null +++ b/apis/dist/cohere/lib/document-tpl.jsonnet @@ -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 + ] +} diff --git a/apis/dist/cohere/lib/request-tpl.jsonnet b/apis/dist/cohere/lib/request-tpl.jsonnet new file mode 100644 index 0000000..4ceb296 --- /dev/null +++ b/apis/dist/cohere/lib/request-tpl.jsonnet @@ -0,0 +1,7 @@ +local openai = import "openai-request-tpl.jsonnet"; + +openai.run("https://api.cohere.com/v2/chat", "bearer") + { + body+: { + model: "command-r", + }, +} diff --git a/apis/dist/google/fixture/document.json b/apis/dist/google/fixture/document.json new file mode 100644 index 0000000..f3c1ee5 --- /dev/null +++ b/apis/dist/google/fixture/document.json @@ -0,0 +1,13 @@ +{ + "doc": [ + { + "type": "markdown", + "content": [ + { + "type": "text", + "text": "Hello! How can I help you today? \n" + } + ] + } + ] +} diff --git a/apis/dist/google/fixture/request.json b/apis/dist/google/fixture/request.json new file mode 100644 index 0000000..1d3800d --- /dev/null +++ b/apis/dist/google/fixture/request.json @@ -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" +} diff --git a/apis/dist/google/fixture/response.json b/apis/dist/google/fixture/response.json new file mode 100644 index 0000000..e4a16b2 --- /dev/null +++ b/apis/dist/google/fixture/response.json @@ -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 + } +} diff --git a/apis/dist/google/lib/document-tpl.jsonnet b/apis/dist/google/lib/document-tpl.jsonnet new file mode 100644 index 0000000..11e6991 --- /dev/null +++ b/apis/dist/google/lib/document-tpl.jsonnet @@ -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 + ]) +} diff --git a/apis/dist/google/lib/request-tpl.jsonnet b/apis/dist/google/lib/request-tpl.jsonnet new file mode 100644 index 0000000..76041e6 --- /dev/null +++ b/apis/dist/google/lib/request-tpl.jsonnet @@ -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 + }], + }], + }, +} diff --git a/apis/dist/package.json b/apis/dist/package.json index 5463b9f..c6745d1 100644 --- a/apis/dist/package.json +++ b/apis/dist/package.json @@ -1,6 +1,6 @@ { "name": "tplfa-apis", - "version": "1.1.4", + "version": "1.1.5", "description": "APIs for API templating", "keywords": [], "author": "Oleg Parashchenko",