Skip to content

Commit 30fe269

Browse files
authored
Update duckduckgo tool option (#439)
1 parent 49c35b8 commit 30fe269

File tree

9 files changed

+48
-8
lines changed

9 files changed

+48
-8
lines changed

.changeset/khaki-cobras-heal.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-llama": patch
3+
---
4+
5+
Deactive duckduckgo tool for TS

.changeset/strange-icons-walk.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-llama": patch
3+
---
4+
5+
Replace DuckDuckGo by Wikipedia tool for agentic template

create-app.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import { makeDir } from "./helpers/make-dir";
1010
import terminalLink from "terminal-link";
1111
import type { InstallTemplateArgs, TemplateObservability } from "./helpers";
1212
import { installTemplate } from "./helpers";
13-
import { writeDevcontainer } from "./helpers/devcontainer";
1413
import { templatesDir } from "./helpers/dir";
1514
import { toolsRequireConfig } from "./helpers/tools";
15+
import { configVSCode } from "./helpers/vscode";
1616

1717
export type InstallAppArgs = Omit<
1818
InstallTemplateArgs,
@@ -105,7 +105,7 @@ export async function createApp({
105105
});
106106
}
107107

108-
await writeDevcontainer(root, templatesDir, framework, frontend);
108+
await configVSCode(root, templatesDir, framework);
109109

110110
process.chdir(root);
111111
if (tryGitInit(root)) {

helpers/copy.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ export const assetRelocator = (name: string) => {
6161
case "README-template.md": {
6262
return "README.md";
6363
}
64+
case "vscode_settings.json": {
65+
return "settings.json";
66+
}
6467
default: {
6568
return name;
6669
}

helpers/tools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export const supportedTools: Tool[] = [
6565
version: "^6.3.5",
6666
},
6767
],
68-
supportedFrameworks: ["fastapi", "nextjs", "express"],
68+
supportedFrameworks: ["fastapi"], // TODO: Re-enable this tool once the duck-duck-scrape TypeScript library works again
6969
type: ToolType.LOCAL,
7070
envVars: [
7171
{

helpers/devcontainer.ts renamed to helpers/vscode.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import fs from "fs";
22
import path from "path";
3+
import { assetRelocator, copy } from "./copy";
34
import { TemplateFramework } from "./types";
45

56
function renderDevcontainerContent(
@@ -29,7 +30,6 @@ export const writeDevcontainer = async (
2930
root: string,
3031
templatesDir: string,
3132
framework: TemplateFramework,
32-
frontend: boolean,
3333
) => {
3434
const devcontainerDir = path.join(root, ".devcontainer");
3535
if (fs.existsSync(devcontainerDir)) {
@@ -46,3 +46,25 @@ export const writeDevcontainer = async (
4646
devcontainerContent,
4747
);
4848
};
49+
50+
export const copyVSCodeSettings = async (
51+
root: string,
52+
templatesDir: string,
53+
) => {
54+
const vscodeDir = path.join(root, ".vscode");
55+
await copy("vscode_settings.json", vscodeDir, {
56+
cwd: templatesDir,
57+
rename: assetRelocator,
58+
});
59+
};
60+
61+
export const configVSCode = async (
62+
root: string,
63+
templatesDir: string,
64+
framework: TemplateFramework,
65+
) => {
66+
await writeDevcontainer(root, templatesDir, framework);
67+
if (framework === "fastapi") {
68+
await copyVSCodeSettings(root, templatesDir);
69+
}
70+
};

questions/simple.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ const convertAnswers = async (
131131
> = {
132132
rag: {
133133
template: "streaming",
134-
tools: getTools(["duckduckgo"]),
134+
tools: getTools(["wikipedia.WikipediaToolSpec"]),
135135
frontend: true,
136136
dataSources: [EXAMPLE_FILE],
137137
},

templates/components/services/python/suggestion.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@ async def suggest_next_questions_all_messages(
6060
return None
6161

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

6870
@classmethod
6971
async def suggest_next_questions(

templates/vscode_settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"python.envFile": ""
3+
}

0 commit comments

Comments
 (0)