Skip to content

Commit

Permalink
Advance llm analysis example (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
sayantikabanik authored Dec 6, 2024
2 parents 3ef8d6d + a669808 commit 1f391c8
Show file tree
Hide file tree
Showing 4 changed files with 368 additions and 264 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import os
from azure.ai.inference import ChatCompletionsClient
from azure.ai.inference.models import UserMessage
from azure.core.credentials import AzureKeyCredential

import intake
from analytics_framework import INTAKE_LOC
from pathlib import Path


CATALOG_LOC = Path.joinpath(INTAKE_LOC, "catalog_entry.yml")
catalog = intake.open_catalog(CATALOG_LOC)
df_input_coral = catalog["global_coral_bleaching"].read()
print(df_input_coral)

client = ChatCompletionsClient(
endpoint="https://models.inference.ai.azure.com",
credential=AzureKeyCredential(os.environ["GITHUB_TOKEN"]),
)

response = client.complete(
messages=[
UserMessage(
content=f"Here is a dataset:\n{df_input_coral}\nCan you provide the code to process and find the top 03 most bleached regions")
],
model="Meta-Llama-3-8B-Instruct",
temperature=0.8,
max_tokens=2048,
top_p=0.1
)
print(response.choices[0].message.content)
47 changes: 41 additions & 6 deletions analytics_framework/intake/catalog_entry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,61 @@ metadata:
sources:
address_sample:
driver: csv
metadata: {
metadata:
source_url: "https://people.sc.fsu.edu/~jburkardt/data/csv/csv.html"
}
args:
urlpath: "https://people.sc.fsu.edu/~jburkardt/data/csv/addresses.csv"

twilio_stock_price:
driver: csv
metadata: {
metadata:
source_url: "https://www.kaggle.com/datasets/sayantikabanik/twilio-stock-price-twlo20162021"
}
args:
urlpath: "{{CATALOG_DIR}}/data/TWLO_stock.csv"

global_coral_bleaching:
description: "van Woesik, R., Burkepile, D. (2022) Bleaching and environmental data for global coral reef sites from 1980-2020. Biological and Chemical Oceanography Data Management Office (BCO-DMO). (Version 2) Version Date 2022-10-14 [if applicable, indicate subset used]. doi:10.26008/1912/bco-dmo.773466.2 [access date] Terms of Use.
This dataset is licensed under Creative Commons Attribution 4.0 (https://creativecommons.org/licenses/by/4.0/)"
driver: csv
metadata: {
metadata:
source_url: "https://www.bco-dmo.org/dataset/773466"
}
args:
urlpath: "{{CATALOG_DIR}}/data/global_bleaching_environmental.csv"
csv_kwargs:
dtype:
ClimSST: object
Distance_to_Shore: object
Percent_Bleaching: object
SSTA: object
SSTA_DHW: object
SSTA_DHWMax: object
SSTA_DHWMean: object
SSTA_DHW_Standard_Deviation: object
SSTA_Frequency: object
SSTA_FrequencyMax: object
SSTA_FrequencyMean: object
SSTA_Frequency_Standard_Deviation: object
SSTA_Maximum: object
SSTA_Mean: object
SSTA_Minimum: object
SSTA_Standard_Deviation: object
TSA: object
TSA_DHW: object
TSA_DHWMax: object
TSA_DHWMean: object
TSA_DHW_Standard_Deviation: object
TSA_Frequency: object
TSA_FrequencyMax: object
TSA_FrequencyMean: object
TSA_Frequency_Standard_Deviation: object
TSA_Maximum: object
TSA_Mean: object
TSA_Minimum: object
TSA_Standard_Deviation: object
Temperature_Kelvin: object
Temperature_Kelvin_Standard_Deviation: object
Temperature_Maximum: object
Temperature_Mean: object
Temperature_Minimum: object
Turbidity: object
Windspeed: object
Loading

0 comments on commit 1f391c8

Please sign in to comment.