Skip to content

Commit

Permalink
Merge branch 'main' of github.com:IncognitaDev/apps into wake-utm-met…
Browse files Browse the repository at this point in the history
…adata
  • Loading branch information
IncognitaDev committed Jan 21, 2025
2 parents adce226 + dab84af commit 86f1149
Show file tree
Hide file tree
Showing 79 changed files with 919 additions and 405 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ jobs:
path: |
/home/runner/.deno
/home/runner/.cache/deno/deps/https/deno.land
- uses: denoland/setup-deno@v1
- uses: denoland/setup-deno@v2
with:
deno-version: v1.x
deno-version: v2.x
- name: Bundle Apps
run: deno run -A --lock=deno.lock --lock-write --reload scripts/start.ts
run: deno run -A --lock=deno.lock --frozen=false --reload scripts/start.ts

- name: Check
run: deno task check
Expand All @@ -47,8 +47,8 @@ jobs:
- name: Test
continue-on-error: true
run: deno test --lock=deno.lock --lock-write -A .
run: deno test --lock=deno.lock --frozen=false -A .

- name: Benchmark
continue-on-error: true
run: deno bench --lock=deno.lock --lock-write -A .
run: deno bench --lock=deno.lock --frozen=false -A .
2 changes: 1 addition & 1 deletion .github/workflows/issues.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.issue.number }}
LABELS: triage
LABELS: triage
16 changes: 8 additions & 8 deletions .github/workflows/releaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ on:
- main

permissions:
contents: write # Necessary for accessing and modifying repository content
pull-requests: write # Necessary for interacting with pull requests
actions: write # Necessary for triggering other workflows
contents: write # Necessary for accessing and modifying repository content
pull-requests: write # Necessary for interacting with pull requests
actions: write # Necessary for triggering other workflows

jobs:
tag-discussion:
Expand All @@ -21,9 +21,9 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.base.ref }} # Checkout the base branch (target repository)
repository: ${{ github.event.pull_request.base.repo.full_name }} # Checkout from the target repo
ref: ${{ github.event.pull_request.base.ref }} # Checkout the base branch (target repository)
repository: ${{ github.event.pull_request.base.repo.full_name }} # Checkout from the target repo

- name: Calculate new versions
id: calculate_versions
run: |
Expand Down Expand Up @@ -162,11 +162,11 @@ jobs:
run: |
git tag ${{ steps.determine_version.outputs.new_version }}
git push origin ${{ steps.determine_version.outputs.new_version }}
- name: Trigger Release Workflow
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.everest-preview+json" \
https://api.github.com/repos/${{ github.repository }}/actions/workflows/release.yaml/dispatches \
-d '{"ref":"main", "inputs":{"tag_name":"${{ steps.determine_version.outputs.new_version }}"}}'
-d '{"ref":"main", "inputs":{"tag_name":"${{ steps.determine_version.outputs.new_version }}"}}'
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<hr/>

<hr/>
<a href="https://deco.cx/discord" target="_blank"><img alt="Discord" src="https://img.shields.io/discord/985687648595243068?label=Discord&color=7289da" /></a>
&nbsp;
<a href="https://x.com/deco_frontend" target="_blank"><img src="https://img.shields.io/twitter/follow/deco_frontend" alt="Deco Twitter" /></a>
Expand Down
10 changes: 10 additions & 0 deletions admin/widgets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ export type SiteRoute = string;
*/
export type MapWidget = string;

/**
* @format date
*/
export type DateWidget = string;

/**
* @format date-time
*/
export type DateTimeWidget = string;

/**
* @format textarea
*/
Expand Down
12 changes: 9 additions & 3 deletions ai-assistants/actions/describeImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { AssistantIds } from "../types.ts";
import { AppContext } from "../mod.ts";
import { logger, meter, ValueType } from "@deco/deco/o11y";
import { shortcircuit } from "@deco/deco";

const stats = {
promptTokens: meter.createHistogram("assistant_image_prompt_tokens", {
description: "Tokens used in Sales Assistant Describe Image Input - OpenAI",
Expand Down Expand Up @@ -78,13 +79,18 @@ export default async function describeImage(
});
return response;
} catch (error) {
const errorObj = error as {
error: { message: string };
status: number;
headers: Headers;
};
stats.describeImageError.add(1, {
assistantId,
});
shortcircuit(
new Response(JSON.stringify({ error: error.error.message }), {
status: error.status,
headers: error.headers,
new Response(JSON.stringify({ error: errorObj.error.message }), {
status: errorObj.status,
headers: errorObj.headers,
}),
);
}
Expand Down
2 changes: 1 addition & 1 deletion ai-assistants/mod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import AWS from "https://esm.sh/aws-sdk@2.1585.0";
import AWS from "npm:aws-sdk@2.1585.0";
import { deferred } from "std/async/deferred.ts";
import openai, {
Props as OpenAIProps,
Expand Down
2 changes: 1 addition & 1 deletion anthropic/deps.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default as Anthropic } from "https://esm.sh/@anthropic-ai/sdk@0.27.3";
export { default as Anthropic } from "https://esm.sh/@anthropic-ai/sdk@0.28.0";
12 changes: 2 additions & 10 deletions decopilot-app/actions/prompt/runPrompt.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// import { shortcircuit } from "@deco/deco";
import { callAntropic, callOpenAI } from "../../clients/llmClientObjects.ts";
import { callAnthropic } from "../../clients/llmClientObjects.ts";
import type { AppContext } from "../../mod.ts";
import type { Attachment, LLMResponseType, Prompt } from "../../types.ts";

Expand Down Expand Up @@ -42,15 +41,8 @@ export default async function action(
}

if (prompt.provider === "Anthropic") {
return await callAntropic(prompt, ctx, attachments ?? []);
return await callAnthropic(prompt, ctx, attachments ?? []);
}

if (prompt.provider === "OpenAI") {
return await callOpenAI(prompt, ctx, attachments ?? []);
}
// if (prompt.provider === "Custom") {
// return await callCustomProvider(prompt, ctx, attachments);
// }

throw new Error(`Provider ${prompt.provider} is not supported`);
}
12 changes: 2 additions & 10 deletions decopilot-app/actions/prompt/runSavedPrompts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// import { shortcircuit } from "@deco/deco";
import { callAntropic, callOpenAI } from "../../clients/llmClientObjects.ts";
import { callAnthropic } from "../../clients/llmClientObjects.ts";
import type { AppContext } from "../../mod.ts";
import type { Attachment, LLMResponseType } from "../../types.ts";

Expand All @@ -24,15 +23,8 @@ export default async function action(
}

if (prompt.provider === "Anthropic") {
return await callAntropic(prompt, ctx, attachments ?? []);
return await callAnthropic(prompt, ctx, attachments ?? []);
}

if (prompt.provider === "OpenAI") {
return await callOpenAI(prompt, ctx, attachments ?? []);
}
// if (prompt.provider === "Custom") {
// return await callCustomProvider(prompt, ctx, attachments);
// }

throw new Error(`Provider ${prompt.provider} is not supported`);
}
25 changes: 1 addition & 24 deletions decopilot-app/clients/llmClientObjects.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// import getAppTools from "../../openai/actions/code.ts";
import { AppContext as AnthropicAppContext } from "../../anthropic/mod.ts";
import { allowedModels } from "../../anthropic/actions/code.ts";

import { AppContext } from "../mod.ts";
import { Attachment, LLMResponseType, Prompt } from "../types.ts";
import assembleFinalPrompt from "../utils/assembleComplexPrompt.ts";

export const callAntropic = async (
export const callAnthropic = async (
prompt: Prompt,
ctx: AppContext,
attachments?: Attachment[],
Expand Down Expand Up @@ -72,28 +71,6 @@ export const callAntropic = async (
// logica pra chamar a openai
};

export const callOpenAI = (
prompt: Prompt,
_ctx: AppContext,
_attachments?: Attachment[],
): LLMResponseType => {
const response: LLMResponseType = {
id: "None",
created: 0,
provider: "OpenAI", // Provider is OpenAI
model: prompt.model,
tools: [""],
llm_response: [{
message: {
role: "Not Ready",
content: `OpenAI functions still not ready`,
},
index: 0,
}],
};
return response;
};

export type Caller = (
prompt: Prompt,
attachments: Attachment[],
Expand Down
2 changes: 1 addition & 1 deletion decopilot-app/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import AnthropicApp from "../anthropic/mod.ts";
// export type AppManifest = ManifestOf<App>;

export type App = ReturnType<typeof Decopilot>;
export type AppContext = AC<App>;
export type AppContext = AC<App> & { prompt: Prompt };

export interface Props {
credentials: Credentials[];
Expand Down
107 changes: 8 additions & 99 deletions decopilot-app/utils/assembleComplexPrompt.ts
Original file line number Diff line number Diff line change
@@ -1,71 +1,7 @@
import { Attachment, Prompt, PromptDetails } from "../types.ts";
import { handleAnthropicAttachments } from "./handleAttachments.ts";
import { handleAttachments } from "./handleAttachments.ts";

export function assembleOpenAIPrompt(
mainPrompt: string,
advanced?: PromptDetails,
handledAttachments?: string | null,
): string {
let finalPrompt = mainPrompt;

if (advanced) {
const { context, examples, restrictions } = advanced;

if (context) {
finalPrompt += `\n\nContext:\n${context}`;
}

if (examples) {
finalPrompt += `\n\nExamples:\n${examples}`;
}

if (handledAttachments) {
finalPrompt += handledAttachments;
}

if (restrictions) {
finalPrompt += `\n\nRestrictions:\n${restrictions}`;
}
} else if (handledAttachments) {
finalPrompt += handledAttachments;
}

return finalPrompt;
}

export function assembleAnthropicPrompt(
mainPrompt: string,
advanced?: PromptDetails,
handledAttachments?: string | null,
): string {
let finalPrompt = mainPrompt;

if (advanced) {
const { context, examples, restrictions } = advanced;

if (context) {
finalPrompt += `\n\n<Context>\n${context}\n</Context>`;
}

if (examples) {
finalPrompt += `\n\n<Examples>\n${examples}\n</Examples>`;
}

if (handledAttachments) {
finalPrompt += handledAttachments;
}

if (restrictions) {
finalPrompt += `\n\n<Restrictions>\n${restrictions}\n</Restrictions>`;
}
} else if (handledAttachments) {
finalPrompt += handledAttachments;
}

return finalPrompt;
}

function assembleFallbackPrompt(
export function assemblePrompt(
mainPrompt: string,
advanced?: PromptDetails,
handledAttachments?: string | null,
Expand Down Expand Up @@ -101,40 +37,13 @@ export default async function assembleFinalPrompt(
prompt: Prompt,
attachments?: Attachment[],
): Promise<string> {
const { provider, prompt: mainPrompt, advanced } = prompt;

let finalPrompt = "";
let handledAttachments = "";

if (attachments) {
handledAttachments = await handleAnthropicAttachments(attachments);
}

switch (provider) {
case "OpenAI":
finalPrompt = assembleOpenAIPrompt(
mainPrompt,
advanced,
handledAttachments,
);
break;
const { prompt: mainPrompt, advanced } = prompt;

case "Anthropic":
finalPrompt = assembleAnthropicPrompt(
mainPrompt,
advanced,
handledAttachments,
);
break;

default:
finalPrompt = assembleFallbackPrompt(
mainPrompt,
advanced,
handledAttachments,
);
break;
}
const finalPrompt = assemblePrompt(
mainPrompt,
advanced,
attachments ? await handleAttachments(attachments) : "",
);

return finalPrompt;
}
4 changes: 3 additions & 1 deletion decopilot-app/utils/handleAttachments.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Attachment, FileURL } from "../types.ts";

export async function handleAnthropicAttachments(
// currently handles using anthropic suggested method

export async function handleAttachments(
attachments: Attachment[],
): Promise<string> {
const treated_Attachments: string[] = [];
Expand Down
4 changes: 2 additions & 2 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
},
"lock": false,
"tasks": {
"check": "deno fmt && deno lint && deno check **/mod.ts",
"check": "deno fmt && deno lint && deno check --allow-import **/mod.ts",
"release": "deno eval 'import \"deco/scripts/release.ts\"'",
"start": "deno run -A ./scripts/start.ts",
"bundle": "deno run -A jsr:@deco/deco/scripts/bundle",
Expand All @@ -62,5 +62,5 @@
"jsx": "react-jsx",
"jsxImportSource": "preact"
},
"version": "0.61.0"
"version": "0.64.5"
}
5 changes: 3 additions & 2 deletions konfidency/loaders/productDetailsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ export default function productDetailsPage(
},
};
} catch (error) {
logger.error(`{ errorName: ${error.name},
errorMessage: ${error.message} }`);
const errorObj = error as { name: string; message: string };
logger.error(`{ errorName: ${errorObj.name},
errorMessage: ${errorObj.message} }`);
return productDetailsPage;
}
};
Expand Down
Loading

0 comments on commit 86f1149

Please sign in to comment.