微信扫码
与创始人交个朋友
我要投稿
.01
.02
.03
.04
.05
pip install azure-ai-openai lotus-nlp pyodbc pandas
# Azure OpenAI SDK
from azure.identity import DefaultAzureCredential
from azure.ai.openai import OpenAIClient
# LOTUS Library
import lotus
# Database Libraries
import pyodbc
import pandas as pd
# Set up Azure OpenAI Client
endpoint = "https://your-openai-resource.openai.azure.com/"
credential = DefaultAzureCredential()
openai_client = OpenAIClient(endpoint=endpoint, credential=credential)
# Set up LOTUS with OpenAI LLM
llm = lotus.OpenAI(azure_openai_client=openai_client)
# Database Connection
conn = pyodbc.connect(
'DRIVER={ODBC Driver 17 for SQL Server};'
'SERVER=your_server;DATABASE=your_database;UID=your_username;PWD=your_password'
)```
# Load data into a Pandas DataFrame
movies_df = pd.read_sql_query("SELECT * FROM movies", conn)
# Create a LOTUS table
movies_table = lotus.Table.from_dataframe(movies_df, name="movies", llm=llm)```
# Apply semantic filter
filtered_movies = movies_table.sem_filter("genre is romance and is considered a classic")
# Sort and select top 5
top_movies = filtered_movies.sort_values(by="box_office", ascending=False).head(5)
print(top_movies[['title', 'box_office']])
# Load financial data
stocks_df = pd.read_sql_query("SELECT * FROM stocks", conn)
stocks_table = lotus.Table.from_dataframe(stocks_df, name="stocks", llm=llm)
# Apply semantic filter
filtered_stocks = stocks_table.sem_filter(
"sector is technology and revenue growth last quarter above 20% and P/E ratio below 15"
)
print(filtered_stocks[['company_name', 'revenue_growth', 'pe_ratio']])
.06
# Assuming patient_data_table is a LOTUS table
filtered_patients = patient_data_table.sem_filter(
"age between 50 and 60 and underwent Procedure X"
)
average_recovery = filtered_patients['recovery_time'].mean()
print(f"Average Recovery Time: {average_recovery} days")
# Assuming customers_table is a LOTUS table
high_value_customers = customers_table.sem_filter(
"purchases over $1,000 last month and high engagement"
)
print(high_value_customers[['customer_id', 'total_purchases', 'engagement_score']])
.07
参考:
53AI,企业落地应用大模型首选服务商
产品:大模型应用平台+智能体定制开发+落地咨询服务
承诺:先做场景POC验证,看到效果再签署服务协议。零风险落地应用大模型,已交付160+中大型企业
2024-11-16
通过Reranking来优化RAG:提升信息检索的精准度
2024-11-15
复旦发布:最佳RAG方案
2024-11-15
破解PDF解析难题:RAG中高效解析复杂PDF的最佳选择
2024-11-15
RAG技术全解析:从基础到前沿,掌握智能问答新动向
2024-11-15
RAG在未来会消失吗?附RAG的5种切分策略
2024-11-15
HtmlRAG:利用 HTML 结构化信息增强 RAG 系统的知识检索能力和准确性
2024-11-15
打造自己的RAG解析大模型:表格数据标注的三条黄金规则
2024-11-13
RAGCache:让RAG系统更高效的多级动态缓存新方案
2024-07-18
2024-07-09
2024-05-05
2024-07-09
2024-05-19
2024-06-20
2024-07-07
2024-07-07
2024-07-08
2024-07-09
2024-11-06
2024-11-06
2024-11-05
2024-11-04
2024-10-27
2024-10-25
2024-10-21
2024-10-21