Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update duckduckgo tool option #439

Merged
merged 5 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/khaki-cobras-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-llama": patch
---

Deactive duckduckgo tool for TS
5 changes: 5 additions & 0 deletions .changeset/strange-icons-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-llama": patch
---

Replace DuckDuckGo by Wikipedia tool for agentic template
4 changes: 2 additions & 2 deletions create-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { makeDir } from "./helpers/make-dir";
import terminalLink from "terminal-link";
import type { InstallTemplateArgs, TemplateObservability } from "./helpers";
import { installTemplate } from "./helpers";
import { writeDevcontainer } from "./helpers/devcontainer";
import { templatesDir } from "./helpers/dir";
import { toolsRequireConfig } from "./helpers/tools";
import { configVSCode } from "./helpers/vscode";

export type InstallAppArgs = Omit<
InstallTemplateArgs,
Expand Down Expand Up @@ -105,7 +105,7 @@ export async function createApp({
});
}

await writeDevcontainer(root, templatesDir, framework, frontend);
await configVSCode(root, templatesDir, framework);

process.chdir(root);
if (tryGitInit(root)) {
Expand Down
3 changes: 3 additions & 0 deletions helpers/copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ export const assetRelocator = (name: string) => {
case "README-template.md": {
return "README.md";
}
case "vscode_settings.json": {
return "settings.json";
}
default: {
return name;
}
Expand Down
2 changes: 1 addition & 1 deletion helpers/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const supportedTools: Tool[] = [
version: "^6.3.5",
},
],
supportedFrameworks: ["fastapi", "nextjs", "express"],
supportedFrameworks: ["fastapi"], // TODO: Re-enable this tool once the duck-duck-scrape TypeScript library works again
type: ToolType.LOCAL,
envVars: [
{
Expand Down
24 changes: 23 additions & 1 deletion helpers/devcontainer.ts → helpers/vscode.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from "fs";
import path from "path";
import { assetRelocator, copy } from "./copy";
import { TemplateFramework } from "./types";

function renderDevcontainerContent(
Expand Down Expand Up @@ -29,7 +30,6 @@ export const writeDevcontainer = async (
root: string,
templatesDir: string,
framework: TemplateFramework,
frontend: boolean,
) => {
const devcontainerDir = path.join(root, ".devcontainer");
if (fs.existsSync(devcontainerDir)) {
Expand All @@ -46,3 +46,25 @@ export const writeDevcontainer = async (
devcontainerContent,
);
};

export const copyVSCodeSettings = async (
root: string,
templatesDir: string,
) => {
const vscodeDir = path.join(root, ".vscode");
await copy("vscode_settings.json", vscodeDir, {
cwd: templatesDir,
rename: assetRelocator,
});
};

export const configVSCode = async (
root: string,
templatesDir: string,
framework: TemplateFramework,
) => {
await writeDevcontainer(root, templatesDir, framework);
if (framework === "fastapi") {
await copyVSCodeSettings(root, templatesDir);
}
};
leehuwuj marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion questions/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const convertAnswers = async (
> = {
rag: {
template: "streaming",
tools: getTools(["duckduckgo"]),
tools: getTools(["wikipedia.WikipediaToolSpec"]),
frontend: true,
dataSources: [EXAMPLE_FILE],
},
Expand Down
8 changes: 5 additions & 3 deletions templates/components/services/python/suggestion.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ async def suggest_next_questions_all_messages(
return None

@classmethod
def _extract_questions(cls, text: str) -> List[str]:
def _extract_questions(cls, text: str) -> List[str] | None:
content_match = re.search(r"```(.*?)```", text, re.DOTALL)
content = content_match.group(1) if content_match else ""
return content.strip().split("\n")
content = content_match.group(1) if content_match else None
if not content:
return None
return [q.strip() for q in content.split("\n") if q.strip()]

@classmethod
async def suggest_next_questions(
Expand Down
3 changes: 3 additions & 0 deletions templates/vscode_settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.envFile": ""
}
Loading