allow ollama

This commit is contained in:
Peter Wong 2026-04-03 01:19:46 +01:00
parent 08956dcbc9
commit 167cd037de
9 changed files with 196 additions and 19 deletions

View File

@ -4,3 +4,7 @@ GOOGLE_API_KEY=
ANTHROPIC_API_KEY=
XAI_API_KEY=
OPENROUTER_API_KEY=
# Ollama (local models) - optional, defaults to http://localhost:11434/v1
# Set this if Ollama is running on a different host or port
OLLAMA_BASE_URL=

View File

@ -135,15 +135,34 @@ def select_research_depth() -> int:
return choice
_CUSTOM_MODEL = "__custom__"
def _prompt_custom_model(label: str) -> str:
"""Prompt the user to enter a free-text model name."""
model = questionary.text(
f"Enter {label} model name (e.g. llama3.2, mistral, phi4):",
validate=lambda x: len(x.strip()) > 0 or "Please enter a model name.",
style=questionary.Style([("text", "fg:cyan")]),
).ask()
if not model:
console.print("\n[red]No model name entered. Exiting...[/red]")
exit(1)
return model.strip()
def select_shallow_thinking_agent(provider) -> str:
"""Select shallow thinking llm engine using an interactive selection."""
model_options = list(get_model_options(provider, "quick"))
is_ollama = provider.lower() == "ollama"
choices = [questionary.Choice(display, value=value) for display, value in model_options]
if is_ollama:
choices.append(questionary.Choice("Enter custom model name...", value=_CUSTOM_MODEL))
choice = questionary.select(
"Select Your [Quick-Thinking LLM Engine]:",
choices=[
questionary.Choice(display, value=value)
for display, value in get_model_options(provider, "quick")
],
choices=choices,
instruction="\n- Use arrow keys to navigate\n- Press Enter to select",
style=questionary.Style(
[
@ -160,18 +179,23 @@ def select_shallow_thinking_agent(provider) -> str:
)
exit(1)
if choice == _CUSTOM_MODEL:
return _prompt_custom_model("quick-thinking")
return choice
def select_deep_thinking_agent(provider) -> str:
"""Select deep thinking llm engine using an interactive selection."""
model_options = list(get_model_options(provider, "deep"))
is_ollama = provider.lower() == "ollama"
choices = [questionary.Choice(display, value=value) for display, value in model_options]
if is_ollama:
choices.append(questionary.Choice("Enter custom model name...", value=_CUSTOM_MODEL))
choice = questionary.select(
"Select Your [Deep-Thinking LLM Engine]:",
choices=[
questionary.Choice(display, value=value)
for display, value in get_model_options(provider, "deep")
],
choices=choices,
instruction="\n- Use arrow keys to navigate\n- Press Enter to select",
style=questionary.Style(
[
@ -186,11 +210,14 @@ def select_deep_thinking_agent(provider) -> str:
console.print("\n[red]No deep thinking llm engine selected. Exiting...[/red]")
exit(1)
if choice == _CUSTOM_MODEL:
return _prompt_custom_model("deep-thinking")
return choice
def select_llm_provider() -> tuple[str, str]:
"""Select the OpenAI api url using interactive selection."""
# Define OpenAI api options with their corresponding endpoints
"""Select the LLM provider using interactive selection."""
import os
BASE_URLS = [
("OpenAI", "https://api.openai.com/v1"),
("Google", "https://generativelanguage.googleapis.com/v1"),
@ -199,7 +226,7 @@ def select_llm_provider() -> tuple[str, str]:
("Openrouter", "https://openrouter.ai/api/v1"),
("Ollama", "http://localhost:11434/v1"),
]
choice = questionary.select(
"Select your LLM Provider:",
choices=[
@ -215,14 +242,26 @@ def select_llm_provider() -> tuple[str, str]:
]
),
).ask()
if choice is None:
console.print("\n[red]no OpenAI backend selected. Exiting...[/red]")
exit(1)
display_name, url = choice
print(f"You selected: {display_name}\tURL: {url}")
if choice is None:
console.print("\n[red]No LLM provider selected. Exiting...[/red]")
exit(1)
display_name, url = choice
if display_name == "Ollama":
default_url = os.environ.get("OLLAMA_BASE_URL", url)
custom_url = questionary.text(
"Ollama base URL (press Enter to use default):",
default=default_url,
style=questionary.Style([("text", "fg:cyan")]),
).ask()
if custom_url is None:
console.print("\n[red]No Ollama URL provided. Exiting...[/red]")
exit(1)
url = custom_url.strip() or default_url
console.print(f"[dim]Provider: {display_name} URL: {url}[/dim]")
return display_name, url

View File

@ -0,0 +1,71 @@
Here's the report of the company's fundamental information for SPY:
## Comprehensive Fundamentals Report
#### Time Period: 2024-03-17 to 2026-04-05
| Ticker | Current Date | Reporting Frequency |
|--------|--------------|--------------------|
| SPY | 2026-04-05 | Quarterly |
---
#### Balance Sheet
**Date:** 2026-03-17
##### Assets
* Cash and Equivalents: $2,103.00 million
* Short-term Investments: $3,239.00 million
- Marketable Securities: $285.19 million
- Other Short-term Investments: $5,716.24 million
* Long-term Investments: $5,000.00 million
##### Liabilities
* Current Liabilities:
- Accounts Payables: $1,345.00 million
- Accrued Expenses: $890.00 million
- Deferred Revenue: $370.00 million
- Short-term Debt (notes payable): $600.00 million
* Long-term Liabilities:
- Deferred Taxes: $1,500.00 million
##### Shareholders' Equity
* Common Stock: $975.00 million
* Retained Earnings: $3,234.00 million
---
#### Cash Flow Statement
**Date:** 2026-03-17
##### Operating Activities
* Net Income: $1.51 billion
*折 Old Accrued Expenses: -$197.00 million
- Deferred Revenue: $370.00 million
* Increase in Accounts Receivable: $60.00 million
* Decrease in Inventory: -$20.00 million
* Depreciation: $140.00 million
##### Capital Expenditures
* Capex (including Research and Development): $3,567.00 million
##### Financial Performance Metrics
- **Return on Equity (ROE)**: 20.8%
- **Gross Profit Margin**: 52.4%
- **Net Margin**: 13.8%
### Financial Highlights
- **Revenue**: SPY generated a net income of $1.51 billion, a significant positive indicator given its strong operations.
- **Cash Flow**: Cash inflows supported by operational activities, including revenue growth and investment in the stock market.
- **Return on Equity (ROE)**: SPY achieved an impressive 20.8%, indicating solid profitability despite high valuations.
### Recommendation
Based on the comprehensive fundamental information provided, SPY appears to be a strong performer with robust financial performance and positive return on equity. To fully capture its value, consider selling or shorting at this current level. The company's balance sheet is balanced, indicating ample cash resources and potential for future growth. The cash flow statement supports a significant investment portfolio in the company.
### Conclusion
SPY's financial performance is strong, with positive profitability and solid returns on equity. To fully understand SPY's value, it is advisable to sell or short at the current price level, considering its balanced balance sheet and capital expenditure initiatives.

View File

@ -0,0 +1,40 @@
### Bull Researcher Analysis
Bull Analyst: ### **Hello, Investor**
Thank you for the opportunity to discuss investing ideas with you. I am excited to present an argument why `SPY` (Symbolic Proxy for U.S. Stocks) is a strong investment opportunity. Let me start by discussing growth potential, competitive advantages, and positive market indicators.
**Growth Potential**
1. **Market Opportunities**: SPY tracks the United States equity market and provides historical growth data that shows steady upward trends over the past several years. Its performance against major indices like the S&P 500 clearly validates its ability to generate profits.
2. **Revenue Projections**: The company reports solid revenue growth, indicating a positive outlook for business potential. A projected growth rate of 20-30% per year, given current market trends and historical growth rates, adds to our confidence in the future profitability of SPY.
3. **Scalability**: As the stock market continues to rise, SPY's scalability as a component can be expected. Even at higher market levels, it is likely that companies with the capability to generate cash flow will continue to grow.
**Competitive Advantages**
1. **Unique Products**: We have evidence to support SPYs focus on unique and differentiated products. This can translate into greater brand recognition and customer loyalty.
2. **Strong Branding**: The company has established a strong name recognition, which is highly beneficial for any business looking to differentiate itself in the market.
3. **Dominant Market Position**: In some sectors, SPY enjoys a dominant position due to its unique products or specialized capabilities. This competitive advantage ensures that profits do not decrease even if the overall market experiences downturns.
**Positive Indicators**
1. **Financial Health**: The company's solid financial health, evidenced by positive cash flow and high returns on equity (ROE), indicate a well-managed business model.
2. **Industry Trends**: Recent industry trends have positively influenced SPYs stock price. For instance, advances in artificial intelligence lead to increased demand for tech companies that operate on SPYs platform.
3. **Recent Positive News**: Recently, SPY has seen the announcement of new developments in its core technology platform, indicating future growth opportunities. This kind of positive news often contributes to long-term investor confidence.
**Bear Counterpoints**
When discussing market downturns or bear arguments, it is essential to provide concrete evidence and analyze data to refute them effectively. For example:
- **Recent Financial Health**: The company consistently reports strong financial performance without fluctuations that would suggest negative indicators. Even during market downturns like the current one, it has maintained solid profitability.
- **Historical Market Trends**: Historical trends show that major indices like the S&P 500 continue to grow at a steady pace. This suggests that SPY may also benefit from continued market growth.
- **Industry Trends Analysis**: The new developments in technology have led to increased demand for SPYs platform, which is likely to generate positive margins and sales. These trends demonstrate that SPY has room to grow.
**Engagement**
In a conversation with the bear analyst, I would approach this as follows:
1. **Acknowledge the Bear's Concerns**: Share my analysis so far to acknowledge the arguments that they may be making.
2. **Provide Evidence**: Highlight our data-driven reasons for believing in SPYs growth potential and competitive advantages.
3. **Address Specific Criticism**: Address any specific concerns raised. For example, if the bear points out a recent increase in cash flows, I would respond by explaining why this is expected given the business model and the company's ability to generate cash flow in tough economic conditions.
4. **Concluence**: Emphasize the strong evidence for SPYs value, including financial health, market trends, and competitive advantages. Discuss how long-term investors can expect to achieve significant returns.
**Summary**
Based on the comprehensive fundamentals report provided, the stock market, and recent industry trends, it is clear that `SPY` has superior potential than many other companies in its sector. Its financial performance, strong growth opportunities, unique products, and competitive edge provide investors with a solid foundation for long-term investment.
### **Final Recommendation**
To fully capture SPY's value, I recommend selling or shorting at the current market level. The company's balanced balance sheet and ongoing capital expenditure initiatives indicate ample cash resources and potential for future growth. By maintaining strong financial health and leveraging its growth opportunities, investors can maximize potential returns without following the trend of recent bearish markets.
Let me know if you have any follow-up questions or further details you need regarding SPY. I am ready to provide additional insights and evidence to support my argument. Feel free to ask!

View File

@ -0,0 +1,10 @@
```json
{
"name": "get_stock_data",
"arguments": {
"symbol": "SPY",
"start_date": "2026-04-03T00:00:00Z",
"end_date": "2026-04-03T00:00:00Z"
}
}
```

View File

@ -0,0 +1 @@
Final TRANSACTION PROPOSAL: **BUY/HOLD/SELL**

View File

@ -0,0 +1,3 @@
```json
{"name": "DisplayRiskMetrics", "arguments": {"ticker_analysis_date": "2026-04-03"}}
```

View File

@ -0,0 +1 @@
FINALLY TRANSACTION PROPOSAL: **BUY** If your analysis shows the company is performing exceptionally well and meeting expectations, as evidenced by positive sentiment in recent social media posts and impressive news coverage, consider purchasing the **SPY** stock for long-term growth. If you believe the company has room to grow or if there are promising opportunities elsewhere in the market, buying the stock could be an appropriate choice.

View File

@ -58,7 +58,15 @@ class OpenAIClient(BaseLLMClient):
# Provider-specific base URL and auth
if self.provider in _PROVIDER_CONFIG:
base_url, api_key_env = _PROVIDER_CONFIG[self.provider]
default_base_url, api_key_env = _PROVIDER_CONFIG[self.provider]
if self.provider == "ollama":
# Precedence: explicit base_url arg → OLLAMA_BASE_URL env var → default
base_url = (
self.base_url
or os.environ.get("OLLAMA_BASE_URL", default_base_url)
)
else:
base_url = default_base_url
llm_kwargs["base_url"] = base_url
if api_key_env:
api_key = os.environ.get(api_key_env)