Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into build-on-helicone
Browse files Browse the repository at this point in the history
  • Loading branch information
colegottdank committed Sep 26, 2024
2 parents d2cf52a + 4ee6645 commit 412786f
Show file tree
Hide file tree
Showing 6 changed files with 848 additions and 362 deletions.
55 changes: 55 additions & 0 deletions docs/integrations/gemini/api/python.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
title: "Gemini Python SDK Integration"
sidebarTitle: "Python"
description: "Use Gemini's Python SDK to integrate with Helicone to log your Gemini AI usage."
"twitter:title": "Gemini Python SDK Integration - Helicone OSS LLM Observability"
icon: "python"
iconType: "solid"
---

<Steps>
<Step title="Create an account + Generate an API Key">
Log into [Helicone](https://www.helicone.ai) or create an account. Once you have an account, you can generate an [API key](https://helicone.ai/developer).
</Step>
<Step title="Create Google Generative AI API Key">
Visit the [Google Generative AI API Key](https://aistudio.google.com/app/apikey) page. Follow the instructions to create a new API key. Make sure to save the key as you will need it for the next steps.
</Step>
<Step title="Set API keys as environment variables">
```bash
export HELICONE_API_KEY=<your Helicone API key>
export GOOGLE_GENERATIVE_API_KEY=<your Google Generative AI API key>
```
</Step>
<Step title="Install the Google Generative AI SDK">
Ensure you have the necessary packages installed in your Python environment:
```bash
pip install google-generativeai
```
</Step>
<Step title="Import and configure the client">
```python
import google.generativeai as genai
import os
genai.configure(
api_key=os.environ.get('GOOGLE_GENERATIVE_API_KEY'),
client_options={
'api_endpoint': 'gateway.helicone.ai',
},
default_metadata=[
('helicone-auth', f'Bearer {os.environ.get("HELICONE_API_KEY")}'),
('helicone-target-url', 'https://generativelanguage.googleapis.com')
],
transport="rest"
)
```

</Step>
<Step title="Generate content using the model">
```python
model = genai.GenerativeModel('gemini-1.5-flash')
response = model.generate_content("The opposite of hot is")
print(response.result)
```
</Step>
</Steps>
1 change: 1 addition & 0 deletions docs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
"group": "API",
"pages": [
"integrations/gemini/api/javascript",
"integrations/gemini/api/python",
"integrations/gemini/api/curl"
],
"icon": "code",
Expand Down
36 changes: 27 additions & 9 deletions valhalla/jawn/src/controllers/private/organizationController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,37 @@ export class OrganizationController extends Controller {
@Request() request: JawnAuthenticatedRequest
): Promise<Result<null, string>> {
const organizationManager = new OrganizationManager(request.authParams);
const memberCount = await organizationManager.getMemberCount(true);
if (memberCount.error || memberCount.data == null || memberCount.data < 0) {
return err(memberCount.error ?? "Error getting member count");
const org = await organizationManager.getOrg();
if (org.error || !org.data) {
return err(`Error getting organization: ${org.error}`);
}

const stripeManager = new StripeManager(request.authParams);
if (org.data.tier === "enterprise") {
// Enterprise tier: Proceed to add member without additional checks
} else if (org.data.tier === "pro-20240913") {
// Pro tier: Update Stripe user count before adding member
const memberCount = await organizationManager.getMemberCount(true);
if (
memberCount.error ||
memberCount.data == null ||
memberCount.data < 0
) {
return err(memberCount.error ?? "Error getting member count");
}

const userCount = await stripeManager.updateProUserCount(
memberCount.data + 1
);
const stripeManager = new StripeManager(request.authParams);

const userCount = await stripeManager.updateProUserCount(
memberCount.data + 1
);

if (userCount.error) {
return err(userCount.error ?? "Error updating pro user count");
if (userCount.error) {
return err(userCount.error ?? "Error updating pro user count");
}
} else {
return err(
"Your current tier does not allow adding members. Please upgrade to Pro to add members."
);
}

const result = await organizationManager.addMember(
Expand Down
4 changes: 2 additions & 2 deletions valhalla/jawn/src/controllers/public/experimentController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class ExperimentController extends Controller {
requestBody
);

if (result.error || !result.data) {
if (result.error) {
this.setStatus(500);
console.error(result.error);
return err(result.error);
Expand Down Expand Up @@ -240,7 +240,7 @@ export class ExperimentController extends Controller {
experiment.dataset.rows = datasetRows;
experiment.hypotheses = [hypothesis];

const runResult = run(experiment);
const runResult = await run(experiment);

return runResult;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import ProviderKeyList from "../../../enterprise/portal/id/providerKeyList";
import AddColumnHeader from "./AddColumnHeader";
import { HypothesisCellRenderer } from "./HypothesisCellRenderer";
import { HypothesisHeaderComponent } from "./HypothesisHeaderComponent";
import { PlusIcon } from "@heroicons/react/24/outline";

interface ExperimentTableProps {
promptSubversionId: string;
Expand Down Expand Up @@ -293,7 +294,12 @@ export function ExperimentTable({
getRowId={getRowId}
/>
</div>
<Button variant="default" onClick={handleAddRow}>
<Button
variant="ghost"
onClick={handleAddRow}
className="max-w-32 flex flex-row space-x-2 text-md"
>
<PlusIcon className="h-6 w-6" />
Add row
</Button>
</div>
Expand Down
Loading

0 comments on commit 412786f

Please sign in to comment.