Skip to content

Commit

Permalink
Various nits (#8478)
Browse files Browse the repository at this point in the history
* Fix Create DataSource link

* fix top k

* close the DataSourcePicker modal when data source is selected

* remove claude-instant-1.2 (deprecated tomorrow)

* switch to count tokens to test anthropic API key

* fix import
  • Loading branch information
spolu authored Nov 6, 2024
1 parent b481411 commit 2aef97f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion front/components/app/blocks/DataSource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export default function DataSource({
<input
type="text"
className={classNames(
"block w-8 flex-1 rounded-md px-1 py-1 text-sm font-normal",
"block w-12 flex-1 rounded-md px-1 py-1 text-sm font-normal",
readOnly
? "border-white ring-0 focus:border-white focus:ring-0"
: "border-white focus:border-gray-300 focus:ring-0"
Expand Down
9 changes: 5 additions & 4 deletions front/components/data_source/DataSourcePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
PopoverTrigger,
ScrollArea,
Searchbar,
Separator,
} from "@dust-tt/sparkle";
import type {
DataSourceViewType,
Expand Down Expand Up @@ -103,6 +102,8 @@ export default function DataSourcePicker({
setFilteredDataSourceViews(newDataSources.slice(0, 30));
}, [spaceDataSourceViews, searchFilter]);

const [open, setOpen] = useState(false);

return (
<div className="flex items-center">
<div className="flex items-center">
Expand All @@ -117,7 +118,7 @@ export default function DataSourcePicker({
"No DataSource"
)
) : (
<PopoverRoot>
<PopoverRoot open={open} onOpenChange={setOpen}>
<PopoverTrigger>
{selectedDataSourceView ? (
<div
Expand All @@ -138,7 +139,7 @@ export default function DataSourcePicker({
<Button variant="outline" label="Select DataSource" isSelect />
) : (
<Link
href={`/w/${owner.sId}/data-sources/spaces`}
href={`/w/${owner.sId}/spaces/${space.sId}`}
className={classNames(
readOnly ? "text-gray-300" : "text-gray-700"
)}
Expand Down Expand Up @@ -169,12 +170,12 @@ export default function DataSourcePicker({
},
]);
setSearchFilter("");
setOpen(false);
}}
>
<div className="my-1">
<div className="text-sm">{dsv.dataSource.name}</div>
</div>
<Separator />
</div>
))}
{filteredDataSourceViews.length === 0 && (
Expand Down
23 changes: 14 additions & 9 deletions front/pages/api/w/[wId]/providers/[pId]/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,34 +95,39 @@ async function handler(
return;

case "anthropic":
const testGenerate = await fetch(
"https://api.anthropic.com/v1/complete",
const testCountTokens = await fetch(
"https://api.anthropic.com/v1/messages/count_tokens",
{
method: "POST",
headers: {
"x-api-key": config.api_key,
"anthropic-version": "2023-06-01",
"anthropic-beta": "token-counting-2024-11-01",
"Content-Type": "application/json",
},
body: JSON.stringify({
prompt: "\n\nHuman: 👋\n\nAssistant:",
model: "claude-instant-1.2",
max_tokens_to_sample: 1,
stop_sequences: [],
model: "claude-3-5-sonnet-20241022",
system: "You are a scientist",
messages: [
{
role: "user",
content: "Hello, Claude",
},
],
}),
}
);

if (!testGenerate.ok) {
const errRes = await testGenerate.json();
if (!testCountTokens.ok) {
const errRes = await testCountTokens.json();
const errType = errRes.error?.type ?? "unknown error";
const errMessage =
errRes.error?.message ?? "contact us at [email protected]";
res
.status(400)
.json({ ok: false, error: `[${errType}] ${errMessage}` });
} else {
await testGenerate.json();
await testCountTokens.json();
res.status(200).json({ ok: true });
}
return;
Expand Down
6 changes: 1 addition & 5 deletions front/pages/api/w/[wId]/providers/[pId]/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ async function handler(
} else {
if (chat) {
anthropic_models = [
{ id: "claude-instant-1.2" },
{ id: "claude-2.1" },
{ id: "claude-3-haiku-20240307" },
{ id: "claude-3-sonnet-20240229" },
Expand All @@ -186,10 +185,7 @@ async function handler(
{ id: "claude-3-opus-20240229" },
];
} else {
anthropic_models = [
{ id: "claude-instant-1.2" },
{ id: "claude-2.1" },
];
anthropic_models = [{ id: "claude-2.1" }];
}
}

Expand Down

0 comments on commit 2aef97f

Please sign in to comment.